"like" and "not like"

  • Thread starter Thread starter Patty
  • Start date Start date
P

Patty

Hi,

I am trying to make my like statement over-ride my not
like statement.

E.g. I am trying to eliminate the word, "cat", "bear" from
my resultset. But I would like to see "dog" and if "cat"
and "bear" happen to be in the same description field then
I do not want to eliminate them.

(like "*dog*") and not like "*cat*" and not like "*bear*" -
does not give me those descriptions where there is even a
single mention of cat or bear even though it has dog.

Pl. help.

Thanks !!
 
Hi Patty,

Not sure if I understand you correctly ...

You want to see:
1.) ALL records where "dog" is in the field, regardless of what else is in
the field.
2.) All OTHER records where "cat" and "bear" are NOT in the field

Is this correct?

If so:

WHERE (db.fld Like "*dog*") OR (Not (db.fld Like "*cat*") And Not (db.fld
Like "*bear*"));
 
Thanks Peter. Sorry for making this confusing.
You are right about # 1 but

#2 - I do not want to see those fields which have cat and
bear in them if they have no dog...so I want to see cat
and bear only if dog is in that field.

Thanks a lot :)
 
Patty said:
E.g. I am trying to eliminate the word, "cat", "bear" from
my resultset. But I would like to see "dog" and if "cat"
and "bear" happen to be in the same description field then
I do not want to eliminate them.

(like "*dog*") and not like "*cat*" and not like "*bear*" -
does not give me those descriptions where there is even a
single mention of cat or bear even though it has dog.

In a Query search criteria, this oughta do what I think you mean:

Like "dog" OR Not Like "cat" OR Not Like "bear"

The Like "dog" part will allow anything containing "dog", regardless of the
cat & bear contents.

Joe F.
 
#2 - I do not want to see those fields which have cat and
bear in them if they have no dog...so I want to see cat
and bear only if dog is in that field.

Well, then... LIKE "*dog*" should do it. It sounds like you want to
see the record if it has dog in it, and not see it otherwise,
regardless of the cat and bear population!
 
Think of order of operations.

Try:

([YourField] Like "*dog*) OR
( ([YourField] Not Like "*cat*") AND
([YourField] Not Like "*bear*") )

The first line select all records with "dog" in YourField regardless of
others. The second & third lines selects all Records that don't have "cat"
OR (normal English language OR here which is actually logically AND, not the
Boolean algebra OR) "bear".
 
Van T. Dinh said:
The first line select all records with "dog" in YourField regardless
of others. The second & third lines selects all Records that don't
have "cat" OR (normal English language OR here which is actually
logically AND, not the Boolean algebra OR) "bear".

Sure, Van, *that* certainly clears it up. ;-)
 
Back
Top