在网上看到的,觉得有必要记录下。
delete students as a from students as a,
(select * from students group by name having count(1)>1) as b
where a.name=b.name and a.id > b.id;
达到了效果,就不知道效率如何。如果有更加好的方法,请赐教,不胜感激!
本文提供了一种使用SQL语句来删除数据库中重复的学生记录的方法。通过子查询找到具有相同姓名但ID更大的记录并将其删除,以此达到清理数据的目的。
在网上看到的,觉得有必要记录下。
delete students as a from students as a,
(select * from students group by name having count(1)>1) as b
where a.name=b.name and a.id > b.id;
达到了效果,就不知道效率如何。如果有更加好的方法,请赐教,不胜感激!

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