Using not in a query

  • Thread starter Thread starter RickM
  • Start date Start date
R

RickM

I have a query of customer records grouped by customer code, week,
sum[sales], using where customer code does not equal "ABC" or "DEF" or
"GHI".

And it pulls all the records. Bummer. I changed where customer code does
not equal "ABC" and it works fine.

Is there any way to use a statement like NOT "ABC" OR "DEF" OR "GHI" for
multiple items not wanted or how does one do this? I've tested setting up a
table listing the codes I don't want but haven't gotten that to work either.

Any help for a feeble mind would be most appreciated. Thanks
 
you need to use "and" not "or"
All records are not "ABC" *OR* not "DEF"


Rick B


I have a query of customer records grouped by customer code, week,
sum[sales], using where customer code does not equal "ABC" or "DEF" or
"GHI".

And it pulls all the records. Bummer. I changed where customer code does
not equal "ABC" and it works fine.

Is there any way to use a statement like NOT "ABC" OR "DEF" OR "GHI" for
multiple items not wanted or how does one do this? I've tested setting up a
table listing the codes I don't want but haven't gotten that to work either.

Any help for a feeble mind would be most appreciated. Thanks
 
You could use:

[customer code] <> "ABC" AND [customer code] <> "DEF" AND [customer code] <>
"GHI"


hth,
 
When you use Not like "ABC" or Not Like "DEF" you get
everything returned because "ABC" and "GHI" are not
like "DEF" and "DEF" and "GHI" are not like "ABC"

Now if you were to say Not like "ABC" AND not like "DEF"
you would only get "GHI"

Use "AND" between your not like criteria not "OR"


Jasper
 
Back
Top