美文网首页
mysql 比较2表不同数据

mysql 比较2表不同数据

作者: AGEGG | 来源:发表于2020-04-02 14:36 被阅读0次

    思路:
    可以用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
    

    https://blog.csdn.net/luyaran/article/details/80928666

    相关文章

      网友评论

          本文标题:mysql 比较2表不同数据

          本文链接:https://www.haomeiwen.com/subject/ieoluhtx.html