Reputation: 611
I wanna do a check in my database if there are emails with multiple userID's. I have tried to query below but it just counts the records that's not realy my goal.
SELECT userID, COUNT(*), email FROM `userAccountCredential` GROUP BY userID HAVING COUNT(*) > 1
Let' say there is an email [email protected] with userID 1 and userID 2 I want to get [email protected] as a result so a list of the emails with multiple userID's.
Upvotes: 0
Views: 1201
Reputation: 204766
SELECT email
FROM `userAccountCredential`
GROUP BY email
HAVING COUNT(distinct userId) > 1
Upvotes: 5