实验报告(三)
 1、实验目的
 (1)掌握等值连接、不等值连接的形式和用途
 (2)掌握自连接的形式和应用场合
 2、实验预习与准备
 (1)了解数据检索时使用多表连接的原因和目的,以及连接条件如何确定
 (2)掌握等值连接和不等值连接的区别
 (3)了解自连接的用法
 3、实验内容及步骤
 (1)查询上过“大学英语”且期末成绩在80到90分之间的学生学号、姓名和学分
 select cno from course where cname=’大学英语’;
 select A.sno,B.sname,B.credit
 -> from score A ,student B
 -> where A.sno=B.sno and A.cno=200101 and A.score between 80 and 90;
 (2)查询计算机学院的女生姓名,及其所选的课程名以及该课程的平时成绩,期末成绩
 mysql> select clno,department
 -> from class
 -> where department=‘计算机学院’;
 ±---------±----------------+
 | clno | department |
 ±---------±----------------+
 | 18010101 | 计算机学院 |
 | 18010201 | 计算机学院 |
 ±---------±----------------+
 2 rows in set (0.00 sec)
 mysql> select sname,cname,usual,score
 -> from student,course,score
 -> where student.clno in(‘18010101’,‘18010102’) and student.sex=‘女’ and student.sno=score.sno and course.cno=score.cno;
 (3)查询李晨老师教过的学生的学号,姓名,电话号码
 mysql> select sno,sname,student.tel
 -> from teacher,student,course_class
 -> where teacher.tname=‘李晨’ and teacher.tno=course_class.tno and course_class.clno=student.clno;
 (4)查询和“张丹丹”老师同一个院系的学生的姓名和院系名称
 mysql> select distinct sname, department
 -> from teacher,student,course_class
 -> where teacher.tname=‘张丹丹’ and teacher.tno=course_class.tno and course_class.clno = student.clno;
 ±----------±-------------+
 | sname | department |
 ±----------±-------------+
 | 秦建兴 | 金融学院 |
 | 张吉哲 | 金融学院 |
 | 王胜男 | 金融学院 |
 | 李楠楠 | 金融学院 |
 | 耿明 | 金融学院 |
 | 贾志强 | 金融学院 |
 | 朱凡 | 金融学院 |
 | 沈柯辛 | 金融学院 |
 | 牛不文 | 金融学院 |
 | 王东东 | 金融学院 |
 ±----------±-------------+
 10 rows in set (0.00 sec)
 (5)查询邮箱不为空并且 “数据库原理”课程期末成绩在80分以上的学生学号、姓名和院系,并按学生院系升序排列,同一院系的学生按出生日期降序排列
 mysql> select distinct student.sno,sname,department
 -> from student,course,score,course_class,class
 -> where student.email!=‘’ and course.cname=‘数据库原理’
 -> and course.cno =score.cno and score.sno=student.sno
 -> and score.score>80
 -> order by department asc,student.birth desc;(6)查询与“贺明明”一个院系的教师编号和名字。
 mysql> select B.tno,B.tname
 -> from teacher A,teacher B
 -> where A.tname=‘贺明明’ and A.department=B.department;
 (7)查询所有出生日期晚于“朱凡”并且性别与之相同的学生姓名、班级名称和院系
 mysql> select birth from student where sname =‘朱凡’;
 ±-----------+
 | birth |
 ±-----------+
 | 2000-05-01 |
 ±-----------+
 1 row in set (0.00 sec)
 mysql> select sname,clname,department
 -> from student,class
 -> where student.birth> 2000-05-01 and student.clno=class.clno;
 (8)查询同时教授“010002”和“010003”号课程的教师信息。
 mysql> select distinct * from teacher,course_class C1,course_class C2
 -> where C1.cno=‘010002’ and C2.cno=‘010003’ and C1.tno=teacher.tno;
 (9)查询在同一门课程中期末成绩相同的学生的学号、课程名称和期末成绩mysql> select A.sno,course.cname,A.score
 -> from score A ,score B,course
 -> where A.score=B.score and A.cno=course.cno
 -> group by A.cno;
 4、实验中的问题及解决方法:
 (1)问题一描述……
 解决方法
 (2)问题二描述
 解决方法5、实验感想与总结