Reputation: 35
I have a table with loads of id's but I don't want to select around 10 id's
First I tried multiple OR but that didn't work then found the IN
SELECT * FROM table WHERE id IN (10, 88, 99)
But this selects those numbers I want all the other numbers so a not equal to needs to go in somewhere
Upvotes: 0
Views: 2475
Reputation: 1771
Try this:
SELECT * FROM table WHERE id NOT IN (10, 88, 99)
Hope this helps
Upvotes: 4
Reputation: 137290
Correct query is:
SELECT * FROM `table` WHERE `id` NOT IN (10, 88, 99)
And your attempt with "multiple OR
s" failed probably because of it should involve "multiple AND
s" and negations like that:
SELECT * FROM `table` WHERE `id`!=10 AND `id`!=88 AND `id`!=99
Upvotes: 2