Skip to content

Instantly share code, notes, and snippets.

@thedarsideofit
Last active April 17, 2018 13:07
Show Gist options
  • Save thedarsideofit/17756d9faad32c5356e08aaac21e8484 to your computer and use it in GitHub Desktop.
Save thedarsideofit/17756d9faad32c5356e08aaac21e8484 to your computer and use it in GitHub Desktop.
buscar-repetidos-actualizar-dominios.sql
--Verificar si va a haber emails repetidos al cambiar todos a @yopmail
-------------------------------------------------------------------------------------------------
SELECT REPLACE(email, SUBSTRING_INDEX(email, '@', -1), 'yopmail.com') as nuevo_email, count(*) as cant
FROM `email`
GROUP BY nuevo_email
HAVING cant > 1
--Actualizar todos los emais a @yopmail
-------------------------------------------------------------------------------------------------
UPDATE email
SET email = REPLACE(email, SUBSTRING_INDEX(email, '@', -1), 'yopmail.com');
UPDATE fos_user
SET
email = REPLACE(email, SUBSTRING_INDEX(email, '@', -1), 'yopmail.com'),
email_canonical = REPLACE(email_canonical, SUBSTRING_INDEX(email_canonical, '@', -1), 'yopmail.com');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment