mysql数据库两个表的比较

mysql数据库两个表的比较,第1张

select id,q3 from (

select id,q3 from (

select m1.id,nvl(m1.q1,0)-nvl(m2.q2,0) q3

from (select id,sum(qian) q1 from 30money group by id) m1

left join (select id,sum(qian) q2 from 23money group by id) m2 on (m1.id=m2.id)) order by q3 asc

) where rownum <=10

希望对你有帮助

思路:

可以用union all 查出所有id group by 后 having 统计为1的即为不同数据,为2的则为相同数据

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

select t1.*, t2.*

from 真实表 t1 full join 临时表 using (id) //using也可写成on t1.id=t2.id

where t1.f!=t2.f or (t1.f is null and t2.f is not null) or (t1.f is not null and t2.f is null)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6105833.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存