mysql去除重复数据 发表于 2017-04-27 更新于 2022-03-14 悟已往之不谏,知来者之可追。实迷途其未远,觉今是而昨非。 保留ID最小的1DELETE FROM NAMES WHERE id NOT IN( SELECT * FROM (SELECT MIN(n.id)FROM NAMES n GROUPBY n.name) x) 保留ID最大的1DELETE FROM NAMES WHERE id NOT IN( SELECT * FROM (SELECT MAX(n.id)FROM NAMES n GROUPBY n.name) x)