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

MySQL数据去重

时间:2018-02-24 23:07:17      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:delete   nbsp   where   sel   having   weight   post   数据   from   

列出数据表中的重复数据:

SELECT name, COUNT(*) FROM product GROUP BY name HAVING COUNT(*) > 1;

删除重复数据:

DELETE FROM products AS A JOIN(SELECT name, COUNT(*), MAX(id) AS id FROM products GROUP BY name HAVING COUNT(*) > 1) AS B ON A.name = B.name WHERE A.id < B.id;

 

MySQL数据去重

标签:delete   nbsp   where   sel   having   weight   post   数据   from   

原文地址:https://www.cnblogs.com/00986014w/p/8467731.html

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