query with exceptions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Having difficulty designing a query that would exclude more than one item,
such as (very simply put) "Not like "a" or "b" or "c"
etc.
Please advise.
Thanks.
 
SWW said:
Having difficulty designing a query that would exclude more than one
item, such as (very simply put) "Not like "a" or "b" or "c"
etc.
Please advise.
Thanks.

SELECT *
FROM TableName
WHERE FieldName <> "a"
AND FieldName <> "b"
AND FieldName <> "c"

or

SELECT *
FROM TableName
WHERE FieldName Not In("a", "b", "c")
 
I'm in the design view of a query pulling up an entire table. In the column
labeled Item Number, I want to pull up a query ignoring Item number "Local"
and "Various".
I have tried the string that you suggested, but got a syntax error on the
commas.
Thanks for your help.
 
In the criteria field put --
<>"Local" and <>"Various"

If you have a very big list to exclude or for that matter to include create
a table for your list. In query design view put the table and do not join.
In the criteria put <>[YourTable].[ListField] to exclude and
[YourTable].[ListField] to pull equal to the list.
 
If you had

NOT In ("Local","Various")

as the criteria and that failed try using semi-colons for the separator.

NOT In ("Local";"Various")

(Regional settings sometimes affect the outcome)
 
Back
Top