Dont Show records with either the word "dwg" in a sentence or the work "tbc " (1 Viewer)

rainbows

Registered User.
Local time
Yesterday, 20:34
Joined
Apr 21, 2017
Messages
425
I put this is my query "Not Like "*dwg*" and it works fine and dont return any records with that word in. but i have now discovered there are other records with the word "tbc" in . i have tried to add "Not Like "*tbc*" also to the same field in the query so i get no records with any of those 2 words in but it does not return what i need.

so if i have 20 records and 2 of them have tbc or drg in it i would like to only see 18 records


Clear gloss polyester overlay. Label 70mm x 38.1mm EU30044CL tbc
Copper plate 0.8mm thick dwg DC4521M1-04

thanks
steve

1678981804415.png
 

plog

Banishment Pending
Local time
Yesterday, 22:34
Joined
May 11, 2011
Messages
11,669
You want AND not OR.

abcdwg is not like "*tbc*" so it makes it through
tbcxyz is not like "*dwg*" so it makes it through


OR - pass one and get though
AND - must pass both to get through.
 

rainbows

Registered User.
Local time
Yesterday, 20:34
Joined
Apr 21, 2017
Messages
425
Thank you. works great ,
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:34
Joined
Feb 19, 2002
Messages
43,484
Let me throw a spanner into the works. Using LIKE is very inefficient since it frequently forces the query engine to do a full table scan. That means, the more rows you add to the table, the slower the query gets. You might want to think about a better way to apply this criteria.

First off, do you really need "LIKE" at all or will "=" work? Then you could use Not In("dwg", "tbc") - that will use an index if one is available and it is the shortest way to code the criteria rather than a not like b and a not like c and a not like d. OR, maybe you need to add a new option to Type or maybe you need another way of categorizing material. Bottom line is to never use "like" when "=" will work:) Sometimes, you have no options. If you are searching for a person and you don't quite know how to spell their name,you might use "LIKE" to get close or use "LIKE" because you have a street name but not an exact address. When you are working with something like I think you might be working with, it is best to categorize your data to make it more efficient to select rows.
 

Users who are viewing this thread

Top Bottom