码迷,mamicode.com
首页 > 数据库 > 详细

关于数据库的去重

时间:2018-06-14 11:37:42      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:没有   group by   重复数据   having   HERE   _id   数据   bsp   let   

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

先删除外键的,以内容分组,查询条数大于一的,将该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);

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

关于数据库的去重

标签:没有   group by   重复数据   having   HERE   _id   数据   bsp   let   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!