oracle用一条sql查出哪些数据不在某个表里

Posted 雅冰石

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle用一条sql查出哪些数据不在某个表里相关的知识,希望对你有一定的参考价值。

思路:将这些数据字符串转换为多行记录,然后再进行对比。

参考了:oracle怎样将字符串转为多行_雅冰石的博客-CSDN博客

#查出SMITH,jiao,zhangsan,lisi这些人中哪些人没在scott.emp里

select * from(
with a as 
(
select ',SMITH,jiao,zhangsan,lisi' name 
from dual
)
select regexp_substr(name,'[^,]+',1,rownum) name
from a
connect by rownum<=length(regexp_replace(name,'[^,]+'))
)
where name not in (select ename from scott.emp)
 

 

以上是关于oracle用一条sql查出哪些数据不在某个表里的主要内容,如果未能解决你的问题,请参考以下文章