我要查出无效客户

解决方案 »

  1.   

    select a.*
          from a,b
    where a.khh =b.khh (+)
         and b.khh is null
      

  2.   

    b.khh(+)是右连接吧,为啥不是a.khh(+)=b.khh and b.khh is null 啊 
      

  3.   


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

  4.   

    select a.*
          from a,b
    where a.khh =b.khh (+)右边的(+)是要显示出全部的a.khh,允许b.khh为空
    要是改成a.khh(+)=b.khh and b.khh is null,  这句话肯定是FALSE,因为要查出全部的b.khh,而b.khh不可能为空。 
    另外not exists 的执行效率比NOT IN 高