pdandan

MySql数据库去重---记录

遇到一个问题就是数据库重复数据去重

1、网上百度,找到一篇原创文章,链接如下:http://blog.csdn.net/jeepxiaozi/article/details/40020069,实验成功,记录下。

1 delete from `unique` where id in (select id from  (select id from `unique` where name in (select name from `unique` group by name having count(name)>1) and id not in(select min(id) from `unique` group by name having count(name)>1)) as tmpresult)  

删除前:删除后:

 2、扩展,根据两个字段去重发现一个简单方法

https://www.zhihu.com/question/33189744

 

1 DELETE p1 from `unique` p1, `unique` p2 WHERE p1.name = p2.name AND p1.uname = p2.uname AND p1.id > p2.id;

 

 

发表于 2017-12-28 11:41  pdandan  阅读(96)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章: