您不妨尝试如下内容:
SELECT email_address,
COUNT(*) number_of_dupes,
GROUP_CONCAT(user_id) users
FROM users
GROUP BY email_address
HAVING COUNT(*) > 1;
试验:
CREATE TABLE users (user_id int, email_address varchar(30));
INSERT INTO users VALUES (1, info1@example.com );
INSERT INTO users VALUES (2, info2@example.com );
INSERT INTO users VALUES (3, info1@example.com );
INSERT INTO users VALUES (4, info2@example.com );
INSERT INTO users VALUES (5, info3@example.com );
INSERT INTO users VALUES (6, info2@example.com );
结果:
+-------------------+-----------------+-------+
| email_address | number_of_dupes | users |
+-------------------+-----------------+-------+
| info1@example.com | 2 | 1,3 |
| info2@example.com | 3 | 2,4,6 |
+-------------------+-----------------+-------+
2 rows in set (0.00 sec)