Answers:
此查询将为您提供电子邮件地址及其使用次数的列表,最常用的地址在前。
SELECT email,
count(*) AS c
FROM TABLE
GROUP BY email
HAVING c > 1
ORDER BY c DESC
如果要完整的行:
select * from table where email in (
select email from table
group by email having count(*) > 1
)
count(1)
stackoverflow.com/questions/2710621/...
这是查询,用于查找email
多个的查询login_id
:
SELECT email
FROM table
GROUP BY email
HAVING count(*) > 1
您将需要第二个(嵌套的)查询来获取login_id
by的列表email
。
谢谢大家:-)我使用下面的内容是因为我只关心这两列,而不关心其余的那列。很棒
select email, login_id from table
group by email, login_id
having COUNT(email) > 1
使用带有内部选择查询的条件,根据需要获取整个记录。
SELECT *
FROM member
WHERE email IN (SELECT email
FROM member
WHERE login_id = abcd.user@hotmail.com)
count(1)
同样有效,并且性能更高。(从堆栈溢出中学到了这个技巧;-)