首页 > 数据库技术 > 详细

关于数据库的去重

时间:2018-06-14 10:32:59      阅读:194      评论:0      收藏:0      [点我收藏+]

数据库中存在大量的重复内容,并且存在着外键关系

先删除外键的,以内容分组,查询条数大于一的,将该id在多对多的表中删除

delete from poem2cls where poem_id in(select id from (select id,count(*)as count from poem group by content having count>1)as a);

然后在删除拥有重复内容的表中的重复数据

 delete from poem where id in(select id from (select id,count(*)as count from poem group by content having count>1)as a);

然后循环,直至没有重复内容

关于数据库的去重

原文:https://www.cnblogs.com/wwg945/p/9181248.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!