mysql> select * from table3 order by id;
+------+-------+
| id | value |
+------+-------+
| 1 | a |
| 1 | b |
| 1 | c |
| 1 | d |
| 2 | a |
| 2 | b |
| 3 | a |
| 3 | b |
| 3 | c |
| 4 | a |
| 4 | b |
+------+-------+
I wanted to select all ids that don’t have a value ‘c’.
It will not simply work by following query:
mysql> select distinct id from table3 where value <> 'c';
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
All I need is only 2 and 4 return.
Thanks for your attention!
1 Answer