34,588
社区成员
发帖
与我相关
我的任务
分享
--想多了,像小三这样就可以了
select *
from a
where not exists (select 1 from b where b.部门 = a.部门 and b.姓名 = a.姓名)
select *
from a
where not exists (select 1 from b where b.部门 = a.部门 and b.姓名 = a.姓名)
union all
select *
from b
where not exists (select 1 from a where b.部门 = a.部门 and b.姓名 = a.姓名)
--2000 or 2005
select a.*
from a join b on a.部门 = b.部门 and a.姓名 = b.姓名
where b.部门 is null
--SQL2000
select *
from A
where not exists (select 1 from b where 部门 = a.部门 and 姓名 = a.姓名)
--SQL2005
select * from a
except
select * from b