Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2008-03-13 : 10:01:54
|
| I have a logic problem, I am selecting from a table [CODE]Select * from TAB_Awhere state not in (1,4)and create_date < '2008-01-01'and((x != 2 and y != 1 and z != 4) or(x != 6 and y != 3 and z != 1) or(x != 8 and y != 0 and z != 9))[/CODE]then for example i am getting results where x,y and z is equal to one or more of above combinations ?Now i vaguely remember that using or with a != messes up the logic ?if so can i use an NOR ? does it exist ? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-03-13 : 10:11:26
|
| I believe it's the OR that's messing you up. x=2,y=1,z=4 can be returned since it satisfies the last 2 conditions. Change the OR to AND.Jim |
 |
|
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2008-03-13 : 10:19:42
|
| Changing the the OR to AND returns 0 results and i know there are cases that should be returned.. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2008-03-13 : 11:08:34
|
| ok now i realise, OR and != is a flaw in logic ....so i can use OR and = and use another table... |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-03-13 : 11:13:16
|
| pazzy11 -- no one can help you with your logic if you cannot express to us exactly what it should be. We can't look at a boolean expression that doesn't work and guess as to what it is supposed to be doing. This is not a SQL problem at all, just a logic problem. be sure you fully understand how AND,OR,=,!=, etc work.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|
|
|