select T1.* from T1 not exists(select 1 from T2 where T1.a=T2.a and T1.b=T2.b)
Select a.* from T1 a, T2 b where (a.a<>b.a and a.b<>b.b)
try---- Select a.* from T1 a left join T2 b ON (a.a<>b.a and a.b<>b.b)
select t.* from tb1 t where not exists(select 1 from tb2 where a = t.a and b = t.b)
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 行) */
select T1.* from T1 not exists(select 1 from T2 where T1.a=T2.a and T1.b=T2.b)
Select a.* from T1 a, T2 b where (a.a<>b.a and a.b<>b.b)
try----
Select a.* from T1 a left join T2 b ON
(a.a<>b.a and a.b<>b.b)
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 行)
*/