Loading

SOQL Query on a multi-select picklist

Publiseringsdato: Apr 6, 2023
Beskrivelse

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. 
Løsning

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.


Read more on how to Query Multi-Select Picklist.
 

Knowledge-artikkelnummer

000386734

 
Laster
Salesforce Help | Article