1,删除数据库中重复的用户名
delete a from user as a, (select min(id) id,name from user group by name ) as b where a.name = b.name and a.id <> b.id;
group by 取出最小的id,然后从表中删除重复数据;
group by name [ having count(id) >1 ]
时间: 2024-10-08 10:29:43
1,删除数据库中重复的用户名
delete a from user as a, (select min(id) id,name from user group by name ) as b where a.name = b.name and a.id <> b.id;
group by 取出最小的id,然后从表中删除重复数据;
group by name [ having count(id) >1 ]