22,294
社区成员
发帖
与我相关
我的任务
分享declare @a table(id int, cpcode int, ddup int)
insert @a values(1, 234, 223344)
insert @a values(2, 324, 443322)
insert @a values(3, 432, 456477)
insert @a values(4, 121, 436789)
insert @a values(5, 323, 652312)
insert @a values(6, 453, 441188)
declare @b table(id int, ddup int)
insert @b values(1, 223344)
insert @b values(2, 443322)
insert @b values(3, 456477)
select * from @a a where not exists(select 1 from @b where a.ddup=ddup)
/*
id cpcode ddup
----------- ----------- -----------
4 121 436789
5 323 652312
6 453 441188
*/
select * from t1 where not exists (select 1 from t2 where t1.ddup=t2.ddup)select * from a where not exists(select 1 from b where a.ddup=b.ddup)SELECT T.*
FROM 表1 T where ddup not in (select ddup from 表2)