• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

How do I make two conditions in an Access Query

Not Like "FFF*" Or Not Like "PHARMEDIUM*"

I am trying to exclude two vendors from an access query.  If I do a not like for one or each of these, it seems to work but if I combine, it does not.  I tried () but not sure I am placing correctly.  Can any one suggest a change above that would work for both when running???
0
vpopper
Asked:
vpopper
  • 3
  • 2
1 Solution
 
vpopperAuthor Commented:
Also, there could be different variations of the vendor name - this is why I used the *
ie. Pharmedium, Pharmedium LTD, Pharmedium Company
0
 
PatHartmanCommented:
Not Like "FFF*" Or Not Like "PHARMEDIUM*"
1. You need to understand Boolean logic.  a <> b or a <> c is ALWAYS true because a cannot be equal to both b and c at the same time unless b and c are equal to each other.  To make this work, you need to use AND rather than OR as the relational operator because you want BOTH statements to be true, not just one of them.

2. I see that you are using the * as a wild card but I just wanted to emphasize that you should NOT use LIKE when you actually have a complete value because in many cases LIKE forces a full table scan and prevents the query engine from optimizing the query.
0
 
vpopperAuthor Commented:
I tried that already and did not work  I solved by using this:
Not Like "FFF*" and Not Like "PHARMEDIUM*"

Thanks
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
vpopperAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for vpopper's comment #a40649826

for the following reason:

Solved this myself
0
 
PatHartmanCommented:
Isn't that what I said?  You may have solved it yourself also, but you did get the correct answer from my post.
0
 
Tony PittCommented:
If you want to combine two negated conditions, then you need to negate a combined condition.  So what you want is something like "Not (Like "FFF" or Like "PHARMEDIUM").  Note that the brackets are important here.

/T
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now