每一年都奔走在自己热爱里

没有人是一座孤岛,总有谁爱着你

SQL删除表中多余的重复记录(多个字段),只留有id最小的记录

delete from jokes

where (title, author, content, url, next) in (select a.title, a.author, a.content, a.url, a.next from (select title, author, content, url, next from jokes group by title, author, content, url, next having count(*) > 1)a)

and id not in (select b.id from (select min(id) id from jokes group by title, author, content, url, next having count(*)>1)b)

 

posted @ 2025-04-15 14:04  helloliyh  阅读(17)  评论(0)    收藏  举报