Lets say I have a MySQL table that has the following entries:
1
2
3
2
5
6
7
6
6
8
When I do an “SELECT * …” I get back all the entries. But I want to get back only these entries, that exist only once within the table. Means the rows with the values 2 (exists two times) and 6 (exists three times) have to be dropped completely out of my result.
I found a keyword DISTINCT but as far as I understood it only avoids entries are shown twice, it does not filters them completely.
I think it can be done somehow with COUNT, but all I tried was not really successful. So what is the correct SQL statement here?
Edit: to clarify that, the result I want to get back is
1
3
5
7
8
You want to mix GROUP BY and COUNT().
Assuming the column is called ‘id’ and the table is called ‘table’, the following statement will work:
This will filter out duplicate results entirely (e.g. it’ll take out your 2’s and 6’s)