View Full Version : "Or" and "Not Like" Operators


fscheer
08-30-2001, 04:36 PM
I have built this very basic query in which I want to filter out a few records. I have attempted several versions of the Not Like "xxx" Or "yyy" or "zzz" criteria (all in the same criteria line, in different lines, in different instances of the same field, etc.) The best I get is the first record specified in the expression filtered out. I have done these before, and don't know why it is not working now. To test that I was sure I was correct in my procedure, I tried the same Not Like expression in a backed up version of the same DB (made a couple days ago), and it worked. When I imported that query into my current DB, it failed to work correctly.
I hope this explains my problem well enough, and I would be appreciative if anyone had any thoughts!
Thanks.

jwindon
08-30-2001, 05:58 PM
It sounds like you need to look at your joins. You may have them going the wrong way.

Jack Cowley
08-30-2001, 08:31 PM
If it works in one db but not the other then I would suggest importing all of the tables, queries, forms etc. from the non-working db into a new empty one. That may clear up your problem....

fscheer
08-31-2001, 08:11 AM
jwindon: The query is a simple filter query, off one field in one table, so there are no joins.

Jack Cowley:
I tried importing to a clean db...that did not work.

I forgot to mention that I tried the Not In ("xxx", "yyy", "zzz") expression, and that does work, but it's not as convenient because you can't use wild cards with that expression.

Pat Hartman
09-02-2001, 04:24 PM
The problem is simply one of understanding boolean logic. Something can only be equal to one thing at a time. Therefore Everything is not equal to one thing or another. For example -
FieldA = 5
The condition
If FieldA <> 5 or FieldA <> 6 - is ALWAYS true because in an OR condition only one of the conditions need to be true. So even though the first part of the condition is false, the second part is true. That makes the whole condition true.

You need to connect the multiple conditions with the AND operator. Then the condition
If FieldA <> 5 And FieldA <> 6 will be false since only the second condition is true but not also the first.

A very simplified boolean logic table for only the And and Or operators:
Operator Cond1 Cond2 Result
And True True True
And True False False
And False True False
And False False False
Or True True True
Or True False True
Or False True True
Or False False False

fscheer
09-10-2001, 09:00 AM
Thanks...using And instead of Or did work. But it still doesn't make sense why using Not Like...Or...Or... DID work on one of my databases (just as the Not Like...And.... worked).

Thanks again.