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


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