0
点赞
收藏
分享

微信扫一扫

sqlite 查找表中多余的重复记录(多个字段) 删除表中多余的重复记录(多个字段),只留有rowid最小的记录

老罗话编程 2022-01-25 阅读 14

查找表中多余的重复记录(多个字段)

select * from answers
where (question_content,options,answers) in (select question_content,options,answers from answers group by question_content,options,answers having count(*) > 1) order by question_content

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

delete from answers
where (question_content,options,answers) in (select question_content,options,answers from answers group by question_content,options,answers having count(*) > 1)
and rowid not in (select min(rowid) from answers group by question_content,options,answers having count(*)>1)

sql代码参考:
SQL删除重复数据只保留一条_anya的专栏-CSDN博客_sql删除重复数据只保留一条

举报

相关推荐

0 条评论