Oracle中exists的使用

-- 如果B中有A中关联的数据,则执行SQL,否则不执行
select A.* from A where exists(select 1 from B where A.name=B.name)
-- 如果exists后子查询结果不为空,则相当于执行:
select A.* from A left join B on A.name=B.name

-- not exists与exists相反
-- 如果子查询为空则执行SQL,否则不执行

发表回复

您的电子邮箱地址不会被公开。

16 + 9 =