Print this page

Querying Multi-Select Picklists in SOQL

Knowledge Article Number 000211744
Description Querying Multi-Select Picklists in SOQL
There are use-cases where you want to use a SOQL query and filter by multi-select picklist values.
The picklist values can be specified with the AND/OR logic. 
Resolution

Use the Semicolon and Comma characters to add filter values to multi-select picklist fields.

A semicolon is used as a special character to specify AND. For example, the following notation: 'AAA;BBB' means ' AAA' and ' BBB':
A comma is used as a special character to specify OR. For example, the following notation: 'AAA','BBB' means ' AAA' or ' BBB':

Examples:

1. Select id, name from Account where MSP1__c includes ('AAA;BBB')

the query filters on values in the MSP1__c field that contains either of these values:
AAA and BBB selected.

2. Select id, name from Account where MSP1__c includes('AAA;BBB','CCC')

the query filters on values in the MSP1__c field that contains either of these values:
AAA and BBB selected.
CCC selected.

3. Select id, name from Account where MSP1__c includes('AAA', 'BBB','CCC')

the query filters on values in the MSP1__c field that contains either of these values:
AAA selected.
BBB selected.
CCC selected.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_querying_multiselect_picklists.htm





promote demote