select T1.* from T1,T2 where T1.a<>T2.2 and T1.b<>T2.b 

解决方案 »

  1.   


    select T1.* from T1 not exists(select 1 from T2 where T1.a=T2.a and T1.b=T2.b)
      

  2.   


    Select a.* from T1 a, T2 b where (a.a<>b.a and a.b<>b.b)
      

  3.   


    try----
    Select a.* from T1 a left join T2 b ON
    (a.a<>b.a and a.b<>b.b)
      

  4.   

    select t.* from tb1 t where not exists(select 1 from tb2 where a = t.a and b = t.b)
      

  5.   

    create table tb1(a int,b int)
    insert into tb1 values(1, 2 )
    insert into tb1 values(1, 1 )
    insert into tb1 values(1, 3 )
    create table tb2(a int,b int)
    insert into tb2 values(1, 1 )
    go
    select t.* from tb1 t where not exists(select 1 from tb2 where a = t.a and b = t.b) 
     
     drop table tb1, tb2
    /*
    a           b           
    ----------- ----------- 
    1           2
    1           3(所影响的行数为 2 行)
    */