Reputation: 741
Duplicate values can be found using this
SELECT email, COUNT(email)
FROM users
GROUP BY email
HAVING COUNT(email) > 1
for the data
ID NAME EMAIL
1 John [email protected]
2 Sam [email protected]
3 Tom [email protected]
4 Bob [email protected]
5 mob [email protected]
But the table I need is
NAME EMAIL
John, Sam, Tom [email protected]
Bob, mob [email protected]
Upvotes: 2
Views: 39
Reputation: 415630
You need the GROUP_CONCAT()
function, which IIRC works in both MySql and Sqlite, but handles NULL values different between the two (I may be wrong on that last part).
SELECT group_concat(name) as Name, email
FROM users
GROUP BY email
HAVING COUNT(email) > 1
Upvotes: 3