记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

Oracle 关于 not in 的坑 ,not in 查询不出数据




select  *

  from A a 
  where  a.id not  in 
    (select b.id

          from B b )


如上查询 如果 当 B表 的 id中有 null 时 此时数据查询不到 


应该为


select  *
  from A a 
  where  a.id not  in 
    (select b.id
          from B b
           where b.id is not  null

     )


因为 not in的子集中不能有 null 
 


转载请标明出处【Oracle 关于 not in 的坑 ,not in 查询不出数据】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论