3.4.2 连接查询
3.4.2 连接查询
一.等值 非等值查询
等值连接 33 查询 每个学生 及其 选修课 的 情况.note
select student.* , sc.*
from sc, student
where sc.sno=student.sno
SC
course
自然连接 34.note
在等值连接中,, 把 重复的 属性列 去掉======自然连接
自身 连接 35.note
查找 每一门课的 间接先修课( 即是 先修课的 先修课)
外连接 36.note
二、
右 外链接 36.note right outer join
左 外链接 36 left outer join
左外链接
select student.sno,sname, ssex, sage, sdept, cno, grade
from student left outer join sc
on (student.sno=sc.sno)
from student left join sc
链接 join.note
查询 选修 1号课程 且 成绩 在 90分以上的 所有学生.note
查询 选修 1号课程 且 成绩 在 90分以上的 所有学生
student 表
SC表
复合条件 链接 37 .note
查询 选修 1号课程 且 成绩 在 90分以上的 所有学生
多表链接 38 .note
select sc.sno, sname , cname, grade
from student, sc,course
where student.sno=sc.sno and sc.cno=course.cno