Loading

oracle exists和 not exists 的用法

比如 a,b 关联列为 a.id = b.id,现在要取 a 中的数据,其中id在b中也存在:

select * from a where exists(select 1 from b where b.id = a.id)

或者:
现在要取 a 中的数据,其中id在b中 不存在:

select * from a where not exists(select 1 from b where a.id = b.id)

 

posted @ 2019-12-01 16:13  青岑  阅读(4146)  评论(0编辑  收藏  举报