DELETE from fa_font_user_consume where id in(
select t.id from (select id from fa_font_user_consume where order_no in (select order_no from fa_font_user_consume group by order_no having count(order_no)>1)
and id not in(select min(id) from fa_font_user_consume group by order_no having count(order_no)>1)) t
)
本文介绍了一种使用SQL语句从数据库表中删除重复记录的方法。通过子查询和分组统计,找出具有相同order_no但ID不是最小的重复记录,并利用DELETE语句进行删除。这种方法适用于需要清理数据中重复项的情况。
1万+

被折叠的 条评论
为什么被折叠?



