mysql 比较2表不同数据
2020-04-02 本文已影响0人
AGEGG
思路:
可以用union all 查出所有id group by 后 having 统计为1的即为不同数据,为2的则为相同数据
SELECT `id` from(
SELECT o.yid as id FROM `ibd_oyihuo` as o WHERE `ystatus` in (1,4) and `yotype` in (6,16,62,66,99999)
UNION ALL
SELECT b.foreign_id as id from ibd_qdzc_commit as b where b.`type`=1 and happen_time=0 and buy_refund=''
) tb1
GROUP BY id
HAVING count(*) = 1
order by id