Ayaz Ali Shah
Ayaz Ali Shah

Reputation: 3531

How can i select all except specific ids using mysql?

I want to select all ids except specific which like 28, 29, 30, 40. I tried following query.

SELECT * FROM oc_product_to_category WHERE product_id !IN  (28, 29, 30, 40)

I searched about it and find this. but it expr IN (28, 29, 30, 40) does not working. Can any is this possible with sql function? I would like to appreciate.

Upvotes: 2

Views: 466

Answers (1)

Giorgos Betsos
Giorgos Betsos

Reputation: 72165

Just use NOT IN:

SELECT * 
FROM oc_product_to_category 
WHERE product_id  NOT IN  (28, 29, 30, 40)

Upvotes: 4

Related Questions