i have multipicklist for industry.

I have a records which has Bank,agriculture as the selected values.

If i need to get all the records have bank and agriculture selected together. Would includes get all records which has industry of bank OR agriculture


Would it give all records with Bank and agriculture ? If it doesnt what should i use to get the and condition?


So the first thing to note is that according to the help docs

Bind expressions can't be used with other clauses, such as INCLUDES.

This means you will probably have to use a dynamic query.

The help docs here give a great run down of the ways to query multi select picklists

For your question:

  1. To query the multi select picklist where Bank AND Agriculture are selected use the clause WHERE Multi_Select__c INCLUDES ('Bank;Agriculture')
  2. To query Bank OR Agriculture as selected use the clause WHERE Multi_Select__c INCLUDES ('Bank', 'Agriculture')
| improve this answer | |
  • Thanks for the link to the doc. It was slightly confusing for me reading through the doc, but your explanation was spot on – Prady May 9 '13 at 6:58

Try something like this

//your query
String query = '';

            if(multiselectList.size() > 0){
                String s = '';
                Integer i = 0;

                for(Id agId : multiselectList){
                        s += '\''+agId+'\'';    
                        s += '\''+agId+'\',';
                query += ' AND Multi_Select__c includes('+ s +')';


This will produce AND Multi_Select__c includes('somthing','something1') and the you can append it to your query. If you want somthing AND something1 you can add it 'something1;something1' as in this doc

Unfortunately multi select list directly can't be used in includes function it is mentioned in this doc

| improve this answer | |

It depends on how you write your query, since you want both to be present you can just use INCLUDES twice:

WHERE MultiPicklist__c INCLUDES ('Bank') AND MultiPicklist__c INCLUDES ('Agriculture')

I've not double checked the syntax for INCLUDES but I'm pretty sure this is correct.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.