第4章 子查询

4.2.1 Exist 谓语:

use TSQLFundamentals2008
select * 
from Sales.Customers as C
where c.country=N'Spain'

select * 
from Sales.Customers as C
where c.country=N'Spain' and exists(select * from Sales.Orders as O where o.custid=C.custid)

select * 
from Sales.Customers as C
where c.country=N'Spain' and not exists(select * from Sales.Orders as O where o.custid=C.custid)
View Code

相关文章: