Skip to content

Instantly share code, notes, and snippets.

@space11
Created February 23, 2023 08:46
Show Gist options
  • Save space11/064cab14816613fe4e8b0d339d8fa1f0 to your computer and use it in GitHub Desktop.
Save space11/064cab14816613fe4e8b0d339d8fa1f0 to your computer and use it in GitHub Desktop.
Find users with the same email address
-- Find users ID that have the same email address
SELECT u.id FROM `user` AS u
INNER JOIN
(
SELECT email FROM `user`
GROUP BY `user`.email HAVING count(id) > 1
) AS u2 ON u2.email = u.email;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment