function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ram sahuram sahu 

How to use includes with set?

Hi All,

I have one doubt that how can i use includes with the set in soql query.

List<LD_Category_Group_Association__c> allLdCatGrpAsslist = [SELECT Id,User_Groups__c FROM LD_Category_Group_Association__c Where User_Groups__c includes (: set_of_LD_User_Groups) ];

Here , User_Groups__c  is a multiple picklist field
ram sahuram sahu
I got Error : Invalid bind expression type of Set<String> for column of type String
TruptiTrupti
Try this:
List<LD_Category_Group_Association__c> allLdCatGrpAsslist = [SELECT Id,User_Groups__c FROM LD_Category_Group_Association__c Where User_Groups__c includes : set_of_LD_User_Groups ];

Thanks
ram sahuram sahu
Hi Trupti,

I tried your code but it gives compiler error that missing '(' , ')' near ':'.
TruptiTrupti
what are values in set_of_LD_User_Groups?
Can you post code for that too?

Thanks
Ajay K DubediAjay K Dubedi
Hi Ram,

Here is some useful link, I hope it will helpful for you:

1. https://developer.salesforce.com/forums/?id=906F00000008yY9IAI
2. https://salesforce.stackexchange.com/questions/46196/soql-query-with-multi-select-picklist-in-where-clause
3. https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_querying_multiselect_picklists.htm
4. https://salesforce.stackexchange.com/questions/11516/how-does-soql-consider-includes-for-multipicklist-and-or-or

Thanks,
Ajay Dubedi