You need to sign in to do that
Don't have an account?
sam_Admin
Help in Query
Hi All,
How to use more than one zip code in query , iam getting error.
Select Id, PostalCode FROM Lead WHERE IsConverted = false AND PostalCode like ('%32814%' ,'%32816%','%32819%')
Try the keyword IN instead of LIKE
Select Id, PostalCode FROM Lead WHERE IsConverted = false AND PostalCode IN ('%32814%' ,'%32816%','%32819%')
It doesn't give me any results if i use IN
Oh my bad! that's because of %
Can you try INCLUDES
I am not sure if it will work as it applies only to multiselect picklists but give it a try.
sry includes doesn't work i tried this and it works but am trying to use postal code everytime, i don't know how to make more simple
Select Id, PostalCode FROM Lead WHERE IsConverted = false AND (PostalCode like '%20814%' or PostalCode like '%20815%' )
Why are you wildcarding the zip codes? Aren't they pretty static?
well some records might have 9 digit and some might have only 5 so iam specifically trying to find out all records for these existing zip codes
For performance and logical reasons, you should ditch the leading wildcard. From a performance standpoint, salesforce has to try to match the entire string within the entire field, instead of just checking from left to right at the beginning. And, of course, you could receive false positives, such as 132814267 (a hypothetical zip code '13281' with a +4 and no hyphen). Don't assume it can't happen, because users are prone to dropping punctuation if they get lazy.
Edit: I should also note that IN does not use wildcards. You'd use LIKE for that comparison.
You are totally right but am fine with 132814267, all i need is the records for the zip code that contains 13281as long as it is 5 or 9 digit
Hi Sam,
you can use SOSL query, which may help to get all the records starting with 32121.
Rgds,
Buss
Make a String List of Postal codes and use IN clause in Query.
For Example :
List<String> PcodeList = new List<String>();
PcodeList .add(32814);
PcodeList .add(32816);
PcodeList .add(32819);
..........
..................[ Select Id, PostalCode FROM Lead WHERE IsConverted = false AND PostalCode IN :PcodeList ];