假设id是主键
AB两表的交集
select a.* from A a where exists (select 1 from B b where b.id=a.id)
A表减交集
select a.* from A a where not exists (select 1 from B b where b.id=a.id)
B表减交集
select b.* from B b where not exists (select 1 from A a where b.id=a.id)