MongoDb去重和MySql去重
db.getCollection('order_trade_info').aggregate([ { $group: { _id: {order_id: '$order_id'},count: {$sum: 1},dups: {$addToSet: '$_id'}} }, { $match: {count: {$gt: 1}} } ]).forEach(function(doc){ doc.dups.shift(); db.getCollection('order_trade_info').remove({_id: {$in: doc.dups}}); })
Mysql
1.根据one列查询重复的数据(根据单列判断重复)
SELECT * FROM testdelete
WHERE ONE IN (SELECT ONE FROM testdelete GROUP BY ONE HAVING COUNT(ONE) > 1)
DELETE FRO
版权声明:
作者:lichengxin
链接:https://www.techfm.club/p/19854.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论