删除重复记录的高效SQL:
delete from student pdi where pdi.rowid in
(select t1.rowid FROM student t1,
(select t.s_no, max(t.id) max_id from student t group by t.s_no having count(*) > 1) t2
where t1.s_no = t2.s_no and t1.id != t2.max_id)
delete from student pdi where pdi.rowid in
(select t1.rowid FROM student t1,
(select t.s_no, max(t.id) max_id from student t group by t.s_no having count(*) > 1) t2
where t1.s_no = t2.s_no and t1.id != t2.max_id)
本文介绍了一种高效的SQL方法来删除数据库中的重复记录,通过使用rowid和group by子句来实现。此方法适用于需要清理数据库中重复数据的情况。
4127

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



