主题:[讨论]EXISTS是怎么理解?还有any,some,all,in
SELECT * FROM ORDERS
WHERE EXISTS(SELECT *FORM ORDERS
WHERE NAME#='SB')
这样会返回orders里面所有的值,而不是只有NAME#='SB'的值
SELECT * FROM ORDERS
WHERE EXISTS
(SELECT * FROM CUSTOMER C WHERE STATE='NE' AND C.NAME#=O.NAME#)
这样确只有返回符合条件WHERE STATE='NE' AND C.NAME#=O.NAME#的值
USE JX
GO
SELECT NAME#,ORDERDON
FROM ORDERS
WHERE NAME#=ALL
(SELECT NAME# FROM ORDERS
WHERE NAME#='TRUE WHELL')
这样可以返回所有的行(orders中有两个值NAME#='TRUE WHELL')
而把all改为any或者some怎么就不会返回任何值呢?用in也是不会有任何值
WHERE EXISTS(SELECT *FORM ORDERS
WHERE NAME#='SB')
这样会返回orders里面所有的值,而不是只有NAME#='SB'的值
SELECT * FROM ORDERS
WHERE EXISTS
(SELECT * FROM CUSTOMER C WHERE STATE='NE' AND C.NAME#=O.NAME#)
这样确只有返回符合条件WHERE STATE='NE' AND C.NAME#=O.NAME#的值
USE JX
GO
SELECT NAME#,ORDERDON
FROM ORDERS
WHERE NAME#=ALL
(SELECT NAME# FROM ORDERS
WHERE NAME#='TRUE WHELL')
这样可以返回所有的行(orders中有两个值NAME#='TRUE WHELL')
而把all改为any或者some怎么就不会返回任何值呢?用in也是不会有任何值