select * from b where not exists(select 1 from a where a.id=b.id)
declare @a table(id int) declare @b table(id int)insert @a select 1 union all select 2 insert @b select 1 union all select 2 union all select 3 select * from @b b where not exists(select id from @a where id = b.id) select * from @b b where id not in (select id from @a )
gahade(与君共勉) 写的select 1 from a where a.id=b.id这个1有什么作用,可以说一下吗
from b
where id not in(select id from a)
where not exists(select 1 from a where a.id=b.id)
declare @b table(id int)insert @a select 1 union all select 2
insert @b select 1 union all select 2 union all select 3
select *
from @b b
where not exists(select id from @a where id = b.id)
select *
from @b b
where id not in (select id from @a )