update xxx_users set username = CONCAT(username,"dup") where exists(
SELECT username, COUNT(username) FROM xxx_users GROUP BY username HAVING COUNT(username) > 1);
update xxx_users u
inner join (
select min(id) id
from xxx_users
group by username
having count(*)>1
) t ON t.id = u.id
set username = CONCAT(username,"dup")
1条答案
按热度按时间fd3cxomn1#
假设你的xxx_users表有一个基于自动递增id的主键,你可以尝试: