清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
查询 columnName 有重复的数据,保留 id 最大的一个。 SELECT MAX(id) AS id, columnName, COUNT(columnName ) AS countNumber FROM tableName GROUP BY columnName HAVING countNumber> 1 ORDER BY countNumber DESC; 删除 columnName 有重复的数据,保留 id 最小的一个。 DELETE tableName t1 FROM tableName t1, (SELECT min(id) id , columnName FROM tableName GROUP BY columnName HAVING COUNT(1) > 1 ) t2 WHERE t1.columnName = t2.columnName AND t1. id > t2.id;