mysql - 如何快速找出三个表的数据是否一致,并找出异同
巴扎黑
巴扎黑 2017-04-17 15:25:52
0
1
431

1.为了快速统计出支付宝的支付方式是否存在漏洞,对支付宝订单的回调建表存储

2.有以下三个表

select notify_id,out_trade_no,trade_no,COUNT(*),notify_time  FROM alipay_callback WHERE trade_status = 'TRADE_SUCCESS' GROUP BY notify_id HAVING COUNT(*) > 1 ORDER BY notify_time
select notify_id,out_trade_no,trade_no,COUNT(*),notify_time  FROM alipay_callback WHERE trade_status = 'TRADE_SUCCESS' GROUP BY out_trade_no HAVING COUNT(*) > 1 ORDER BY notify_time
select notify_id,out_trade_no,trade_no,COUNT(*),notify_time  FROM alipay_callback WHERE trade_status = 'TRADE_SUCCESS' GROUP BY trade_no HAVING COUNT(*) > 1 ORDER BY notify_time

3.当上述三个表一致时视为数据正常,如何快速比较三个表,并且找出不一致的数据?

巴扎黑
巴扎黑

reply all(1)
PHPzhong

Personally, I suggest you do it in your application. Don’t put very complex logic in SQL, even if the SQL only has a few lines and the program has dozens of lines. SQL is the place for storage and query, and the program is where the logic is done. It is easy to implement, easy to maintain, easy to expand, and easy for future generations to understand

If you use an app to do this, I believe there will be no problem. If the data is large, do it in batches according to notify_time

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!