直接上sql:
delete from tablename where id not in (select min(id) from tablename group by field_name);
该语句的解释为:先根据要去重的字段进行分组,查询出最小的id,这些id为不重复的id;然后删除记录的时候只要排除掉这些id即可
本人参考自:https://www.sohu.com/a/148078629_505779 好的博客要分享!
2023-12-10 14:28:39
直接上sql:
delete from tablename where id not in (select min(id) from tablename group by field_name);
该语句的解释为:先根据要去重的字段进行分组,查询出最小的id,这些id为不重复的id;然后删除记录的时候只要排除掉这些id即可
本人参考自:https://www.sohu.com/a/148078629_505779 好的博客要分享!