简体   繁体   中英

Select only unique rows

Let's say I have this table:

  term
---------
park
park
apple
lamp
lamp
park
lamp
orange
orange
banana
orange

And I want to get all unique rows, so my query should return this:

apple
banana

How can I do it? All examples I find uses DISTINCT but that is not what I need.

SELECT `term`
FROM `table`
GROUP BY `term`
HAVING COUNT(`term`) = 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