读书人

数据库有关问题 EXIST的用法 大家帮小

发布时间: 2012-01-26 19:40:46 作者: rapoo

数据库问题 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

读书人网 >SQL Server

热点推荐