如何在MySQL中找到重复的条目

时间:2015-08-09 23:50:09

标签: mysql sql duplicates

我正在尝试这段代码:

SELECT Email FROM 
(SELECT Email, COUNT(Email) AS cnt
FROM Person
GROUP BY Email
HAVING cnt(*) >1 ) 

这个问题: enter image description here 不确定我错了什么?

这是我收到的错误:

 Runtime Error Message: Line 6: SyntaxError: near '*) >1 )'
Last executed input: {"headers": {"Person": ["Id", "Email"]}, "rows": {"Person": []}} 

3 个答案:

答案 0 :(得分:3)

console.log

您根本不需要嵌套查询。

答案 1 :(得分:1)

SELECT Email
FROM Person
GROUP BY Email
HAVING COUNT(*) >1  

SQL FIDDLE

答案 2 :(得分:0)

 select p.email from person p
 join (
 SELECT Email, COUNT(Email) AS cnt
 FROM Person
 GROUP BY Email
 HAVING count(email) > 1)  s
 on s.email = p.email

您无法在havingwhere子句中使用列的别名。