SQL删除表中多余的重复记录(多个字段都是重复的)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lbx_15887055073/article/details/82025659

SQL删除表中多余的重复记录(多个字段都是重复的)

delete from user a
where (a.id,a.name) in (select id,name from user group by id,name having count(*) > 1)
and id not in (select min(id) from user group by id,name having count(*)>1)

只留有rowid最小或者最大的记录,其余的均删除。

展开阅读全文

没有更多推荐了,返回首页