Query mull and more

  • Thread starter Thread starter Mao Monsalve
  • Start date Start date
M

Mao Monsalve

Hi

I have 2 fields 1 and 2 the
field_2 I have A,B,C,D,F,G,etc AND null,
I don'y need C,D,F
I want to get back: null,A, B, C, etc
I try to put on WHERE is null or <>"C" or <>"D" or <>"F"
but doesn't work
jus work isf I use is null or <>"C"

any Ideas how can i get back::null,A, B, C, etc

Thanks
 
I try to put on WHERE is null or <>"C" or <>"D" or <>"F"
but doesn't work

Change your OR to AND.

If the field is equal to C then you can be sure that it is NOT equal
to D - so the clause <> "D" will be true.

OR means "if the expression on either side of this OR is true, the
result is true" so the OR expression will be the same as no criteria
at all - all records will be retrieved.

AND means "if both expressions are TRUE retrieve the record; if either
one of them is FALSE, don't".
 
John, Thanks for you respond.

If I change Or to And, yes I don't get C,D and F. But I
don't get my NUll records neither And I need the NULL
record for the report

any other idea

Thanks again
MM
 
Dear Mao:

My personal preference would be:

WHERE field_2 IS NULL OR field_2 NOT IN("C", "D", "F")

The logic reads much more easily.

The alternative logic would be:

WHERE Field_2 IS NULL OR (field_2 <> "C" AND field_2 <> "D" AND
field_2 <> "F")

Your problem appears to be one of logic.

I recommend you not try to build this in the design grid. The logic
is complex enough without being mangled.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
THANKS Tom works
-----Original Message-----
Dear Mao:

My personal preference would be:

WHERE field_2 IS NULL OR field_2 NOT IN("C", "D", "F")

The logic reads much more easily.

The alternative logic would be:

WHERE Field_2 IS NULL OR (field_2 <> "C" AND field_2
 
John, Thanks for you respond.

If I change Or to And, yes I don't get C,D and F. But I
don't get my NUll records neither And I need the NULL
record for the report

Add

OR IS NULL

to the criterion.

A perhaps more efficient way to do this is to use a criterion of

NOT IN("C", "D", "F") OR IS NULL
 
Back
Top