简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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