oracle exists和 not exists 的用法

Posted 啄木鸟伍迪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle exists和 not exists 的用法相关的知识,希望对你有一定的参考价值。

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)

以上是关于oracle exists和 not exists 的用法的主要内容,如果未能解决你的问题,请参考以下文章

oracle中的exists 和not exists 用法详解

oracle中in,not in和exists,not exists之间的区别

oracle exists和 not exists 的用法

oracle exists和 not exists 的用法

oracle中的exists 和not exists 用法详解

Oracle,用left join 替代 exists ,not exists,in , not in,提高效率