where student.sno=course.sno/*等值连接*/
9. 对第8题用自然连接完成
select student.sname,student.sno, student.sdept, student.sex, student.sbirth,cno,grade
from student,sc
where student.sno=sc.sno/*自然连接*/
10. 查询每一门课的间接先修课(即先修课的先修课)
Select http://www.doczj.com/doc/31a2bbc1941ea76e58fa0491.htmlo,s.cpno
from course f ,course s
where s.cpno=http://www.doczj.com/doc/31a2bbc1941ea76e58fa0491.htmlo/*自身连接*/
11. 如何用外连接的方法改写第8题
Select student.*,course.*
from student left out join sc on (student.sno=sc.sno)/*外连接*/
12. 查询选修2号课程且成绩在90分以上的所有学生
Select student.*
from student,sc
where grade>90 and cno=’2’ and student.sno=sc.sno
13. 查询每个学生的学号、姓名、选修的课程名及成绩
Select student.sno,student.sname,http://www.doczj.com/doc/31a2bbc1941ea76e58fa0491.htmlo,grade
from student,course,sc
where student.sno=course.sno and
http://www.doczj.com/doc/31a2bbc1941ea76e58fa0491.htmlo=http://www.doczj.com/doc/31a2bbc1941ea76e58fa0491.htmlo/*三表连接*/
14. 查询与“杨树超”在同一个系学习的学生(用三种以上不同的方法查询)
1.嵌套查询
Select sno
from student
where sdept in (select from student where sname=’杨树超’)
2.自身连接查询
select sno
from student f,student s
where f.sdept=s.sdept and s.sname=’杨树超’
3.逐步查询
select sdept
from student