[MySQL] 특정 값 중복되는 튜플만 뽑기

테이블

Person 테이블

id email
1 a@b.com
2 c@d.com
3 a@b.com

문제

  • 중복되는 email만 뽑으시오

SELECT p.email AS email 
FROM Person p
GROUP BY p.email 
HAVING COUNT(*) > 1
;

스키마

Create table If Not Exists Person (id int, email varchar(255));
Truncate table Person;
insert into Person (id, email) values (1, 'a@b.com');
insert into Person (id, email) values (2, 'c@d.com');
insert into Person (id, email) values (3, 'a@b.com');

links

social