How to use Salesforce Multipicklist field in SOQL?

Consider here BillingState  is a Multipicklist and we need to list out only certain states like California and New York.
We can achieve using either INCLUDES or EXCLUDES Operators (its working only multi-select picklists).

Example 1:
list<Account> lstACC = [SELECT Id, Name, BillingState, Country FROM Account where BillingState INCLUDES (‘California’, ‘New York’)];
system.debug(‘LIST OF ACCOUNT’ + lstACC);

Example 2:
String states = ‘California;New York’;
List<Account> lstACC = [select Id, Name, BillingState, Country FROM Account where BillingState INCLUDES  (:states) LIMIT 100];
system.debug(‘LIST OF ACCOUNT’ + lstACC);

To Know more about, CLICK HERE

(2157)

Written by 

I am Sakthivel Madesh, a certified Salesforce Developer & Administrator working on Salesforce Technology since 2011. I am currently working in IBM Austraila as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 10 Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply