update login a,
(select a.id
from login a,
(select email, count(id) as num
from login
group by email
having count(id) >= 2) b
where a.email = b.email) b
set a.email = concat(a.id, '@old-email.local')
where a.id = b.id
在来个oracle的
update login
set email = concat(id, '@old-email.local')
where email in (select email
from login
group by email
having count(*) > 1)
你好,我尝试了一下(数据库为mysql),sql如下:
在来个oracle的
单一的sql实现起来比较复杂,可以考虑存储过程,先把重复的记录查询出来,游标遍历更新即可