Reputation: 24099
I know I can exclude a row like so:
SELECT * FROM products WHERE id <>1
But I need to exclude 2 products, I've tried:
SELECT * FROM products WHERE id <>(1,2)
But no luck.
Upvotes: 0
Views: 47
Reputation: 2843
Try this
SELECT * FROM products WHERE id not in (1,2)
IN
is definately faster than OR
. See this MYSQL OR vs IN performance
Upvotes: 3
Reputation: 167250
Use NOT
:
SELECT * FROM `products` WHERE `id` NOT IN (1, 2);
Performance wise, IN
is faster than comparison!
Upvotes: 0