Problem with "OR"

B

bladelock

I have a problem with thi query. I'm trying to display all the data except
for PRO and NICK. When I run this query it still displays them. How do I
exclude them??

Take a look at the query:

SELECT DenialNumbers.ID, DenialNumbers.name, DenialNumbers.[notice
received], DenialNumbers.[Review Agency]
FROM DenialNumbers
WHERE DenialNumbers.[Review Agency]<>"PRO" OR DenialNumbers.[Review
Agency]<>"NICK";
 
J

John W. Vinson

I have a problem with thi query. I'm trying to display all the data except
for PRO and NICK. When I run this query it still displays them. How do I
exclude them??

Take a look at the query:

SELECT DenialNumbers.ID, DenialNumbers.name, DenialNumbers.[notice
received], DenialNumbers.[Review Agency]
FROM DenialNumbers
WHERE DenialNumbers.[Review Agency]<>"PRO" OR DenialNumbers.[Review
Agency]<>"NICK";

Change the OR to AND.

A WHERE clause returns the record if it evaluates to TRUE as a logical
expression. The problem you may be having is that OR is both an English
language conjunction and a Boolean algebra operator... and they aren't exactly
the same!

If the Review Agency is "NICK" then the first clause of your WHERE is TRUE
(because PRO is certainly not equal to NICK). OR means "if either clause is
true return true" - so you'll get all records. You want to return the record
if BOTH conditions - not equal to PRO and not equal to NICK - are True; the
AND operator will do this.

It might be simpler (and more readable) to use

WHERE DenialNumbers.[Review Agency] NOT IN("PRO" , "NICK")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top