MySQL 去重
- 方式一
DELETE FROM t_test
WHERE id IN
(SELECT * FROM
(SELECT MAX(id) did FROM t_test GROUP BY username HAVING COUNT(*) > 1) t);
- 方式二
DELETE FROM t_test
WHERE id NOT IN
(SELECT t.minno FROM
(SELECT MIN(id) AS minno FROM t_test GROUP BY username) t);
执行效率一优于二
—转载请注明出处