How do I update an email containing a double dot in its domain using raw mysql query?
So I have these emails having this format [email protected]
and turn it to this [email protected]
How do I update an email containing a double dot in its domain using raw mysql query?
So I have these emails having this format [email protected]
and turn it to this [email protected]
replace
should do the trick:
UPDATE mytable
SET email = REPLACE(email, '..', '.')
WHERE email LIKE '%..%'
You just need to use '%@%..%' as a like condition to extract all emails that have double dot on the domain. Then split the text by @, replace in the domain and concatenate the text.
select email
,concat(left(email,instr(email,'@')),replace(right(email,instr(reverse(email),'@')-1),'..','.')) new_email
from
(
select '[email protected] ' email
union
select '[email protected]'
union
select '[email protected]'
) t
where email like '%@%..%'