编写一个 SQL 查询,查找 Person
表中所有重复的电子邮箱。
+----+---------+
| Id | Email |
+----+---------+
| 1 | a@b.com |
| 2 | c@d.com |
| 3 | a@b.com |
+----+---------+
方案一:分组
select Email from Person group by Email having count(*)>1;
方案二:内关联表
select distinct p1.email from person person p1,person p2 where p1.id>p2.id and p1.email=p2.email;