MySQL 同时更新存在的相同用户名信息

导入时发现用户名重复..xxx,于是找到这条SQL.运行ok


 

UPDATE users a ,(SELECT  username  FROM  users WHERE  id>4106  GROUP  BY  username  HAVING  COUNT(username) > 1) b
SET a.username=CONCAT(a.username,a.id) WHERE a.username=b.username