日期:2014-05-16 浏览次数:20465 次
select * from A left join B on A.companyid=B.companyid and A.productid=B.productid
union
select * from B left join A on A.companyid=B.companyid and A.productid=B.productid
select a.companyid as a_companyid, a.productid as a_productid, b.companyid as b_companyid, b.productid as b_productid
from a left join b on a.companyid = b.companyid and a.productid = b.productid
where b.companyid is null
union all
select a.companyid as a_companyid, a.productid as a_productid, b.companyid as b_companyid, b.productid as b_productid
from b left join a on a.companyid = b.companyid and a.productid = b.productid
where a.companyid is null