Reputation: 421
I'm trying to select from table, excluding where id is something, say 7.
I have tried: SELECT * FROM table where not exists(select * from table where user_id = '7');
Could anyone direct my to a place where I could get info on this?
Upvotes: 0
Views: 6621
Reputation: 19989
You can do:
SELECT * FROM your_table WHERE id NOT IN(7);
You can find more comparison operators via the Mysql Docs on the subject.
Upvotes: 4
Reputation: 36512
You can invert equality in your WHERE condition, like this:
SELECT field FROM table WHERE id != 7;
Upvotes: 0