Loading

How to Query a Multi-Select Picklist Field Using SOQL in Salesforce

Publiceringsdatum: Jun 10, 2026
Beskrivning

In Salesforce SOQL, querying multi-select picklist fields requires special syntax because these fields can hold multiple semicolon-separated values stored in a single field. Standard equality operators (=) do not work correctly with multi-select picklist fields.
Instead, Salesforce provides the INCLUDES and EXCLUDES keywords for filtering multi-select picklist values. Within the filter values:

  • A semicolon (;) acts as AND logic — the record must have both values selected.
  • A comma (,) acts as OR logic — the record must have at least one of the values selected.
Lösning

Using INCLUDES with Semicolons for AND Logic

To find records where both 'AAA' and 'BBB' are selected in the multi-select picklist field, use a semicolon between the values inside single quotes with the INCLUDES keyword. For example, to query the Account object's MSP1__c multi-select picklist field for records where both AAA and BBB are selected:
Query structure: SELECT id, name FROM Account WHERE MSP1__c INCLUDES ('AAA;BBB')
This returns records where the field contains both AAA and BBB as selected values.

Using Semicolons and Commas for Combined AND/OR Logic

To find records where ('AAA' AND 'BBB' are both selected) OR ('CCC' is selected alone), combine a semicolon (for AND) and a comma (for OR). For example:
Query structure: SELECT id, name FROM Account WHERE MSP1__c INCLUDES('AAA;BBB','CCC')
This returns records that have (AAA and BBB both selected) or (CCC selected).

Using Commas for OR Logic Across Multiple Values

To find records where 'AAA', 'BBB', or 'CCC' is selected (any one of the three), separate each value with a comma. For example:
Query structure: SELECT id, name FROM Account WHERE MSP1__c INCLUDES('AAA', 'BBB','CCC')
This returns records where the field contains AAA selected, or BBB selected, or CCC selected.

Knowledge-artikelnummer

000386734

 
Laddar
Salesforce Help | Article