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!

try:

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.