首页 做网站 MYSQL数据库删除表中重复数据只保留一条

MYSQL数据库删除表中重复数据只保留一条


2017-01-26476 views

delete from think_user where id in (select id from (select  max(id) as id,count(username) as count from think_user group by username having count >1 order by count desc) as tab )


其中think_user为表名,username为其中一个字段


网上找了很多方法,测试结果只有这好用,不知道是不是数据库版本问题。


2009-2017 © diubo.com

0.036920s