关于数据库的去重

时间:2018-06-14 10:32:59   收藏:0   阅读:196

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

先删除外键的,以内容分组,查询条数大于一的,将该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
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!