select A as E,B as F from table1unionselect C as E,D as F from table2

解决方案 »

  1.   

    select a,b
    from table1 left join table2
    on table1.a = table2.c and table1.b = table2.d
    where table2.c is null
      

  2.   

    select a,b
    from table1 left join table2
    on table1.a = table2.c and table1.b = table2.d
    where table2.c is null
      

  3.   

    用一个函数把两个字段合并成一个字段。比如select * from Table1 
    where convert(varchar(100),A)+convert(varchar(100),B) 
    not in(select convert(varchar(100),C)+convert(varchar(100),D) from Table2) 这样应该是可以实现,但方法很笨,抛装引玉。
      

  4.   

    select A, B from table1 where not exists 
     (select C, D from table2 where table1.A = table2.C and 
                                    table1.B = table2.D)
      

  5.   

    select A, B from table1 where not exists 
     (select C, D from table2 where table1.A = table2.C and 
                                    table1.B = table2.D)
      

  6.   

    select A,B 
    from table1
    where not exists (select C,D from table2 where table1.A=table2.C and table1.B=table2.D) as mm