Select excluding multiple records in the same field Not Like

  • Thread starter Thread starter Ian Eagland
  • Start date Start date
I

Ian Eagland

Hi

We have a database where one field contains a name - Laser, Phantom
etc.

We select multiple records with the same name using like "la*" or like
"pha*" and that works fine.

However we now need a selection that excludes about 6 names.

That is the complete database other than those like "la*" and those like
"pha*" etc.

Can this be done?

I have tried a lot of different syntaxes but cannot achieve what I am
after

Regards

Ian Eagland
 
Dear Ian:

Have you tried this?

WHERE SomeColumn NOT LIKE "la*" AND SomeColumn NOT LIKE "pha*"

One of the tricks of logic is that the opposite of "A OR B" is "NOT A
AND NOT B." When A and B are mutually exclusive, "NOT A OR NOT B" is
always true, and therefore not useful.

Anyway, that has been a common problem in situations similar to yours.
So I'm taking a guess this may be your solution.

Free advice, and worth every cent.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Just to add to Tom's post, if your field contains Null values, the criteria
suggested will exclude those records, which may not be what you expect. If
you want to include those records, you might use something like this:

WHERE
(SomeColumn NOT LIKE "la*" AND SomeColumn NOT LIKE "pha*")
OR
(SomeColumn Is Null)
 
Tom said:
Dear Ian:

Have you tried this?

WHERE SomeColumn NOT LIKE "la*" AND SomeColumn NOT LIKE "pha*"

One of the tricks of logic is that the opposite of "A OR B" is "NOT A
AND NOT B." When A and B are mutually exclusive, "NOT A OR NOT B" is
always true, and therefore not useful.

Anyway, that has been a common problem in situations similar to yours.
So I'm taking a guess this may be your solution.

Free advice, and worth every cent.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts

Hi Tom

Many thanks, that solved it. I really appreciate you taking the time to
answer.


Regards

Ian
 
Back
Top