比如a表
A  B  C  D
1  c  d  e
3  e  r  t
4  y  u  6
ABC為聯合主鍵
B表
A  B  C  D
1  c  d  e
3  e  r  tABC為聯合主鍵
怎么找出a表ABC字段在b表沒有的數據呢?
好久沒有搞數據庫了,忘記了,大家幫助一下

解决方案 »

  1.   

    select b.* from a Right Join b on a.a=b.a and a.b=b.b and a.c=b.c
      

  2.   

    select * from #t where not exists (select * from #t1 where #t1.a=#t.a and #t1.b=#t.b and #t1.c=#t.c)
      

  3.   

    nnd,剛剛想出來了,分沒有了~跟ls的一樣
      

  4.   

    select a.* from a where cast(a as varchar) + ',' + cast(b as varchar) + ',' + cast(c as varchar) not in (select cast(a as varchar) + ',' + cast(b as varchar) + ',' + cast(c as varchar) from b)