SELECT * FROM a where not exists (select 1 from b where a.id=b.id)
select * from a where not exists (select 1 from b a.id = b.id)
少 where 居然写错了!!!
create table A(id int) insert into A select 1 union all select 2 union all select 3 create table B(id int) insert into B select 2 union all select 3--#2 select * from A where not exists(select top 1 1 from B where B.id = A.id) --#2 select * from A except select * from B
--#3 select A.id from A outer apply (select top(1) * from B where B.id = A.id) b where B.id is null
where not exists (select 1 from b where a.id=b.id)
select *
from a
where not exists (select 1 from b a.id = b.id)
少 where 居然写错了!!!
insert into A select 1 union all select 2 union all select 3
create table B(id int)
insert into B select 2 union all select 3--#2
select * from A
where not exists(select top 1 1 from B where B.id = A.id)
--#2
select * from A
except
select * from B
select A.id from A
outer apply
(select top(1) * from B where B.id = A.id) b
where B.id is null