有两表,一张是总表ALL(包括字段:A、B、C、D、E),另外一张是分表OTHER(包括字段A1、B1、C1、D1、E1),欲要找ALL表有,但OTHER没的记录,或者是OTHER有,ALL表没有的记录.烦请高手帮忙!

解决方案 »

  1.   


    --ALL中有,other中没有。
    select * from ALL a where not exists(select 1 from OTHER where a1=a.a and b1=a.b and c1=a.c
    and d1=a.d and e1=a.e)
      

  2.   

    有两表,一张是总表ALL(包括字段:A、B、C、D、E),另外一张是分表OTHER(包括字段A1、B1、C1、D1、E1),欲要找ALL表有,但OTHER没的记录,或者是OTHER有,ALL表没有的记录.烦请高手帮忙!select * from all t where not exists(select 1 from other where a1 = t.a and b1 = t.b and c1 = t.c and d1 = t.d and e1 = t.e)select * from other t where not exists(select 1 from all where a = t.a1 and b = t.b1 and c = t.c1 and d = t.d1 and e = t.e1)
      

  3.   

    谢谢,请问可以用left join实现吗?还有,想问"select 1 from other where a1 = t.a and b1 = t.b and c1 = t.c and d1 = t.d and e1 = t.e"中的1是代表什么意思?小弟初接触SQL,烦请解答!
      

  4.   

    left join不行.1代表是否存在数据