mysql - How to select all the unique gmail emails from a set of emails? -
i noticed gmail doesn't care if .
exists in email or not, means ex.ample@gmail.com
equivalent exam.ple@gmail.com
, nice feature google, pita developers trying maintain list of unique email addresses.
i have table list of emails. exact rules gmail uses detect unique email, , given set of emails, how find actual unique emails?
here's schema:
sql> select * subscribers; id | email ------------------------- 1 | user.name1@gmail.com 2 | username.1@gmail.com 3 | user3@example.net ...
the expected output set of unique (and valid!) emails:
id | email ------------------------- 1 | user.name1@gmail.com 3 | user3@example.net
select em, count(*) ( select replace(email, '.','') em subscribers email '%@gmail.com%') t group em having count(*) = 1;
is trying do?
edit: select distinct emails
select distinct concat(replace(substring(email,1,instr(email,'@')-1),'.',''), substring(email,instr(email,'@'))) subscribers;
Comments
Post a Comment