简体   繁体   English

Mysql仅选择唯一的行(仅出现一次)

[英]Mysql select only unique rows (that appears only one time)

Consider following data in table -> 考虑表中的以下数据->

1   example@hotmail.com
2   example12@hotmail.com
3   example@hotmail.com
4   example@hotmail.com

I want it to return only the following: 我希望它只返回以下内容:

2   example12@hotmail.com

...and skip the duplicate values. ...并跳过重复的值。

The query you want is 您想要的查询是

SELECT id, email, whatEverColumn 
FROM table 
WHERE email IN (SELECT email 
               FROM table 
               GROUP BY email 
               HAVING COUNT(id) = 1)

通过电子邮件分组并添加计数(电子邮件)= 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM