0

Let's say that I want to retrieve rows from just one table and exclude rows with certain ID's.
Hypothetical table:

+----+-------+------+
| id | value | type |
+----+-------+------+
| 1  |  foo  | cool |
+----+-------+------+
| 2  |  bar  | cool |
+----+-------+------+
| 3  |  lor  | cool |
+----+-------+------+
| 4  |  ips  | cool |
+----+-------+------+
| 5  |  asd  | cool |
+----+-------+------+
| 6  |  qwe  | warm |
+----+-------+------+

The rows I want is the rows that are of the type "cool" and id not equal to 2, 3 and 5. How would I write this?
My guess so far has been something like this, but it doesn't work:

SELECT * FROM table WHERE type='cool' AND id != 2,3,5

How can I achieve what I want in the most efficient way?
All replies are greatly appreciated!

Thank you!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by gunnarflax
1

try:

SELECT * FROM table WHERE type='cool' AND (id NOT IN(2,3,5) )
0

Thank you! I think that solved it, I'll let you know if it doesn't work :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.