oracle之exist 语句
EXISTS里的子查询结果集非空,EXISTS()子句的值就是true。
EXISTS里的子查询结果集为空,EXISTS()子句的值就是false。
NOT EXISTS里的子查询结果为非空,NOT EXISTS()字句的值是false
NOT EXISTS里的子查询结果为为空,NOT EXISTS()字句的值是true
例如:
SELECT * FROM S_C_INFORMATION WHERE EXISTS (SELECT 1 FROM DUAL)
能查到结果集
------------------------------------------
SELECT * FROM S_C_INFORMATION WHERE EXISTS (SELECT T.NODE_NAME FROM S_C_NODE T WHERE T.NODE_ID='001' )
结果集为空
------------------------------------------
SELECT * FROM S_C_NODE_INFORMATION WHERE NOT EXISTS (SELECT T.NODE_NAME FROM S_C_NODE_INFORMATION T WHERE T.NODE_ID='001' )
能查到结果集
-------------------------------------------
SELECT * FROM S_C_INFORMATION WHERE NOT EXISTS (SELECT 1 FROM DUAL)
结果集为空