注册 登录
编程论坛 SQL Server论坛

关于exist和not exist地用法的问题

dabendan 发布于 2007-06-30 23:56, 3857 次点击

谁能给当多个not exist 用时怎么灵活应用阿,比如说那些至少全选了所有科目的学号之类的问题,看到我就头大了,好像感觉脑子转不过来一样,请各位高手指点!谢谢!!!

3 回复
#2
yushui2007-07-01 10:48
查询所有选修了1号课程发学生姓名
select Sname
from Student
where exists
(select *
from Sc
where Sno=Student.Sno and Cno='1');
查询所有未选修1号课程发学生姓名
select Sname
from Student
where not exists
(select *
from Sc
where Sno=Student.Sno and Cno='1');

#3
yushui2007-07-01 10:52

带exists的子查询一些不能被替换 但是所有带in 比较运算符any all都可以被它代替
我边看书边说 现在也糊涂了

#4
guoxhvip2007-07-04 00:53
exists可以作为where语句的子查询,但一般使用在if语句的存在检测
1