Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm having that table:
|OrderID|Criterion|Status|
|304    |1        |true  |
|304    |2        |false |
|304    |3        |4     |
|305    |1        |false |
|305    |2        |true  |
|305    |3        |4     |


Now i want to select where OrderID is a given one, and where the Status isn't true or false.

What I have tried:

SQL
select * from tblAuftragMulti
where OrderId = '305' and Status != 'true'
or OrderId = '305' or Status != 'false'
Posted
Updated 25-Jul-19 0:17am

1 solution

Try:
SELECT * FROM tblAuftragMulti
WHERE OrderId = '305' AND 
      Status != 'true' AND 
      Status != 'false'
But you shouldn't be storing data like that: you are repeating strings a lot and that leads to errors when someone adds a row with "TRUE" or "False" and it fails to match your criteria. You'd probably be better off a separate table containing the text strings, and a foreign key to the ID; then use a JOIN to get the text back if you need it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900