sql中的谓词exists的详解是什么?

来源:百度知道 编辑:UC知道 时间:2024/06/05 11:03:29

就是存在的意思。举个常用例子:
select a.*
from 同学录 a
where exists (select 1 from 请柬 b where b.姓名=a.姓名)
列出同学录中,有请柬的同学的所有信息。

就是是否存在相应的记录啊
if Exists(select Name from TableName where Name='userName')
begin
...//如果存在userName的用户,则...
end
else
begin
...//如果不存在userName的用户,则...
end

1、
exists 是判断的意思,通常后面有一个被判断的条件使用格式为:
exists(被判断的条件)如果被判断的条件为真则返回值为真(ture),如果被判断的条件为假则返回值为假(false)

2、
与not exists相对,其意思恰恰和上面相反,调用格式是相同的。