查找重复数据
编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱。
Screen Shot 2020-04-09 at 10.08.49 PM.pngSolution1
select Email
from Person
group by Email
having count(Email) > 1;
Solution2
自连接:不建议使用
Select distinct a.Email
From Person a join Person b
on a.Email=b.Email and a.Id<>b.Id
网友评论