Best way to add criteria when there are a lot of them

jereece

Registered User.
Local time
Today, 06:43
Joined
Dec 11, 2001
Messages
300
What is the best way to add criteria when there are a lot of them? For example, I have a field called [site_cd]. I want the query to only return records for certain groups. However, I have about 50 groups. Is there a better way to accomplish this than a long string of "or Like" such as "Like "ABC" or Like "DEF" or Like "XYX"....etc.?

Thanks,
Jim
 
What is the best way to add criteria when there are a lot of them? For example, I have a field called [site_cd]. I want the query to only return records for certain groups. However, I have about 50 groups. Is there a better way to accomplish this than a long string of "or Like" such as "Like "ABC" or Like "DEF" or Like "XYX"....etc.?

Thanks,
Jim

Important Observation and Question:

LIKE is most often used for variable comparisons (LIKE "*ABC" or LIKE "DEF*" or LIKE "*XYX*" ). It appears that using LIKE would not be required in your case, since LIKE "ABC" or LIKE "DEF" or LIKE "XYX" can also be expressed as = "ABC" or = "DEF" or = "XYX"

If this is true, then consider using IN ("ABC", "DEF", "XYX") as an alternative.

-- Rookie
 
Just a thought - May be a bit simple, but is it easier to exclude what you don't want instead? Would save having to add more criteria at a later date if you get new style of references being input.
 
Thanks for the suggestions. Useful information. I had considered excluding but that population is even larger.
 

Users who are viewing this thread

Back
Top Bottom