where aa.col1 not in (select bb.col1 from bb) and aa.col2 not in (select bb.col2 from bb)

解决方案 »

  1.   

    可以使用聯接﹐而且速度更快﹗
    select *from aa  left join bb on aa.字段1=bb.字段1 and aa.字段2=bb.字段2
    where bb.字段1 is null or bb.字段2 is null
      

  2.   

    select * from aa 
    where exists(select 1 from bb where aa.字段1=bb.字段1 and aa.字段2=bb.字段2)
      

  3.   

    可以使用聯接﹐而且速度更快﹗如果是三個字段
    select *from 表2  left join 表1 on 表2.編碼=表1.編碼 and 表2.顏色=表2.編碼 and 表2.編碼=表2.編碼
    where bb.字段1 is null or bb.字段2 is null