Click here to Skip to main content
14,382,476 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm having that table:
|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:

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100