两个表:
a  
a1,a2,a3
b
a1,b2,b3
想找出a表中中不包含在b表的纪录

select * from a where a.a1 not in (select a1 from b)
怎么查不出结果啊!

解决方案 »

  1.   

    select * from a where not exists(select 1 from b 
     where b.b1=a.a1 and b.b2=a.a2 and b.b3=a.a3)
      

  2.   

    select * from t1 A
    where not exists
    (select 1 from t1 where a1=A.a1 )
      

  3.   

    如果表中不存在下列数据类型:text、ntext、image、cursor ,可以考虑使用CheckSum
    对于列数不固定的尤其有用:select * from a where checksum(*) not in (select checksum(*) from b)