Forum Moderators: open
Some of these will be obvious (hotmail, gmail, yahoo etc addresses), but I'm looking for duplicates.
Is there any way that I can build an SQL query that will pull out a list of email addresses where there is more than one on the same domain?
Thanks,
TJ
SELECT DISTINCT(RIGHT(LCASE(email), LEN(email) - INSTR(email, '@'))) FROM tbl; The email addresses were example1@gmail.com, example2@gmail.com, caseexample@GmAiL.CoM, bob@example.com, yahootesting123@yahoo.com, & testagainwithabadaddressbutcapitalthistime@YAHOO.com.
Returned values
example.com
gmail.com
yahoo.com
Edit - after re-reading your question, I don't think I really answered it. I'll have to mess with it some more...
MySQL said: Documentation
#1064 - You have an error in your SQL syntax near '( `email_address` ) - INSTR( `email_address` , '@' ) ) ) FROM subscriber LIMIT ' at line 1
Here's my actual query:-
SELECT DISTINCT (
RIGHT( LCASE( `email_address` ) , LEN(
`email_address`
) - INSTR( `email_address` , '@' ) )
)
FROM subscriber
LIMIT 0 , 30
SELECT DISTINCT (
RIGHT( LCASE( email ) , LENGTH( email ) - INSTR( email, '@' ) )
)
FROM tbl
LIMIT 0 , 30 And it does return example.com. I've tried to get it to only return duplicates, but can't figure out how.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[`email_address`]),Len([`email_address`])-InStr([`email_address`
Exact Query:-
SELECT DISTINCT (
Right( LCase( [ `email_address` ] ) , Len(
[ `email_address` ]
) - InStr( [ `email_address` ], '@' ) )
) AS Expr1, Count( (
[ `email_address` ]
) ) AS Expr2
FROM `subscriber`
GROUP BY (
Right( LCase( [ `email_address` ] ) , Len(
[ `email_address` ]
) - InStr( [ `email_address` ], '@' ) )
)
HAVING (
(
(
Count( (
[ `email_address` ]
) )
) >1
)
)
LIMIT 0 , 30