前言 书上这么写的,先看from,再看where,最后选出满足的行
select * from A where exists (select * from A where Code1111)
等同于
select * from A where exists (select 1 from A where Code1111)
因爲exits是返回true和false,…
比如在Northwind数据库中有一个查询为
SELECT c.CustomerId,CompanyName FROM Customers c
WHERE EXISTS(
SELECT OrderID FROM Orders o WHERE o.CustomerIDc.CustomerID) 这里面的EXISTS是如何运作呢?子查询返回的是OrderId字段,可是外面的查询要找的…
EXISTS
语法:
SELECT 字段 FROM table WHERE EXISTS (subquery);
参数:
subquery是一个受限的SELECT语句(不允许有COMPUTE子句和INTO关键字)
示例:
SELECT * FROM A WHERE EXISTS (SELECT 1 FROM B WHERE B.id …