Reputation: 3481
SELECT * FROM table WHERE id != 4;
SELECT * FROM table WHERE NOT id = 4;
SELECT * FROM table WHERE id <> 4;
I've got this all working but I also have to choose another field (or more fields) to decide what rows are returned.
How can I get this working?
Upvotes: 0
Views: 914
Reputation: 3481
select * from albums where idAlbum
!= 4 and idAlbum
!= 8 I just solve my problem. Thanks for the help guys!
Upvotes: 0
Reputation: 882716
If you want to 'deselect' columns where both conditions are true (ID1
is 4 and ID2
is 7), use something like:
select * from TBL where ID1 <> 4 or ID2 <> 7;
ID1 ID2 selected
--- --- --------
4 7 no
4 1 yes
1 7 yes
1 1 yes
If you want to 'deselect' columns where either condition is true (ID1
is 4 or ID2
is 7), use something like:
select * from TBL where ID1 <> 4 and ID2 <> 7;
ID1 ID2 selected
--- --- --------
4 7 no
4 1 no
1 7 no
1 1 yes
This can be extended to more conditions simply by adding them to the end of the where
clause (and changing both/either
to all/any
in the text).
Upvotes: 1