日期:2014-05-18  浏览次数:20357 次

数据库问题 EXIST的用法 大家帮我解决一下 谢谢
书上说EXIST代表存在量词.带有EXIST谓词的子查询不返回任何实际数据,他只产生ture或者false    

那么下面这个列子  查询未修1号课程的学生姓名 
  select   name   from   trstudent   where   not   exists
            (select   *   from   trscorce   where   studentid=trstudentid   and   courseID=1)

意思是()内只返回ture或者false??  
那么整句不就变成了 select   name   from   trstudent   where   ture   ?   那是什么意思啊?

------解决方案--------------------
当where后面的句子成立的时候,就做前面的。。。
------解决方案--------------------
这个等价于select name from trstudent where trstudent.id not in
(select * from trscorce where studentid=trstudent.id and courseID=1)


------解决方案--------------------
(select * from trscorce where studentid=trstudentid and courseID=1)
--有记录就返回True,否则返回false