Where with existing它在subselect with variable without link中的工



我对EXISTS子句有一个问题:我有一个使用它的查询,但使用了我从未见过的代码。

在子选择的WHERE中,我看到这样的表达式:

WHERE 
@var IS NULL 
OR EXISTS(another subselect)

但这个变量不能与他的select和subselect进行链接。

这是怎么回事?

where @var is null是布尔条件

如果@var为null,则为true,否则为false。

or exists (select '' from table t 
where t.id = s.id and date > '2012-12-1')

如果子查询至少存在一行,则返回true。

如果@var不为空,则针对真实条件评估exists

最新更新