50 - 查找重复的电子邮箱
Last updated
Was this helpful?
Last updated
Was this helpful?
编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱。
示例:
+----+---------+ | Id | Email | +----+---------+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +----+---------+
根据以上输入,你的查询应返回以下结果:
+---------+ | Email | +---------+ | a@b.com | +---------+
说明:所有电子邮箱都是小写字母。
之前拼两个表的做法失效了,因为只出现一次放在两个表里面,就是出现两次了。。
作者:LeetCode 链接:
Runtime: 186 ms, faster than 83.25% of MySQL online submissions forDuplicate Emails.
Memory Usage: N/A
Runtime: 203 ms, faster than 56.22% of MySQL online submissions forDuplicate Emails.
Memory Usage: N/A
group by
的筛选条件是having
select
is where
join
is on
为啥不统一一下???
感觉用having比差临时表要低效呢。
Group by email
,意思是将挑选的结果展示,email
相同,对应值加在一起。
(sub-query),第一个搜索表一定要起一个别名,所以要加一个as,估计是为了方便以后用这个临时表。