1 2 3 4 5 6 7 8 9 |
#从学生表中删除姓名重复的学生记录, 仅保留重复记录中id最大的一条 delete a from t_student as a join (select name, max(id) as maxid from t_student group by name having count(*) > 1 ) as b on a.name = b.name and a.id < b.maxid |