查询重复数据
select max(account_id) as account_id,organ_idno,count(organ_idno) as nums from al_account group by organ_idno having count(organ_idno) > 1;
删除重复值
delete from al_account where account_id in (select t.account_id from (select max(account_id) as account_id from al_account group by organ_idno having count(organ_idno) > 1) as t);
delete from `user`
where id not in (select id from (select min(id) as id from `user` group by `name`) t)
这篇博客介绍了如何在数据库中查找并删除重复的数据。通过SQL查询语句,首先选择每个organ_idno下最大account_id,然后删除account_id在这些最大值中的记录,从而实现删除重复值。同时,该方法也适用于其他表,如`user`表。
382

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



