与测试共存,与朋友共勉!
SQL语句实例 5
上一篇 /
下一篇 2010-05-15 15:30:41
/ 个人分类:转载
6.5外连接查询
select student.sno,sname,ssex,sage,sdept,cno,grade
from student,sc
where student.sno = sc.sno(*)
6.6复合条件连接查询
select student.sno, student.sname
from student, sc
where student.sno = sc.sno and sc.cno= ' 2 ' and sc.grade > 90
七.嵌套查询
7.1带有in谓词的子查询
select sno,sname③最后在student关系中
from student取出sno和sname
where sno in
(select sno②然后在sc关系中找出选
from sc修了3号课程的学生学号
where cno in
(select cno①首先在course关系中找出“信
from course息系统”的课程号,结果为3号
where cname= ‘信息系统’));
7.2带有比较运算符的子查询
select sno,sname,sdept
from student
where sdept =
select sdept
from student
where sname= '刘晨';
7.3带有any(某个)或all(任何一个)谓词的子查询
用all谓词select sname,sage
from student
where sage < all
(select sage
from student
where sdept= ' is ') and sdept <> ' is ’;
用集函数select sname,sage
from student
where sage <
(select min(sage)
from student
where sdept= ' is ') and sdept <>' is
7.4带有exists谓词的子查询
select sname
from student
where not exists
(select *
from sc
where sno = student.sno and cno='1');
收藏
举报
TAG: