MySQL数据去重
列出数据表中的重复数据:
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;