首页 > 代码库 > SQL 删除表中重复记录只剩一条

SQL 删除表中重复记录只剩一条

 

今天不小心插入数据时插入重复了

这表中没有任何主键外键,随便插入或删除

网上查了很多复杂的语句都没有解决问题

最后用delete top (1) 解决问题

delete top (1) from Persion where name = xiaomin


也可以用

update  top (1) from person where name =‘xxxx‘

delete from person where name = ‘xxxx‘

 

没那么复杂

 

SQL 删除表中重复记录只剩一条