+ Start a Discussion
ajitvermaajitverma 

multipicklist soql

hi,

how can i give the where clause(with like keyword) in SOQL for a multipicklist type field.


Thanks
Ajit
Adam BreenAdam Breen

The syntax you are looking for is:

 

SELECT fieldname1, fieldname2, ... , fieldnameN  

FROM objectname

WHERE picklistname INCLUDES ('string1', 'string2', ... , 'stringN')

 

Concrete example:

 

SELECT Id, Name

FROM Account

WHERE myCustomPicklist__c INCLUDES ('bob', 'steve')

 

nb:  I'm no expert (only just found the solution myself), but it appears that INCLUDES behaves as a logical OR operation...

i.e. "includes 'bob' OR includes 'steve'"

 

Cheers!

 

Deshraj KumawatDeshraj Kumawat

Yes ADAM,

 

INCLUDES behaves as logical OR operator, If we need to fetch the records matching the all selected values in multi-picklist field , we need to give semicolon(;) seperated values in INCLUDES clause.

 

i. e. 

 

SELECT Id, Name

FROM Account

WHERE myCustomPicklist__c INCLUDES ('bob;steve')

 

This SOQL will return only the records in which we selected both the values (bob and steve) for this multi-picklist field.

 

THANK YOU!!

SAKTHIVEL MSAKTHIVEL M

Hi,

 

Yes we can achieve using INCLUDES or EXCLUDES Operators,

 

http://theblogreaders.com/how-to-use-salesforce-multipicklist-field-in-soql

 

 

Thanks,

http://theblogreaders.com/

Gomathi SGomathi S

Thanks for your Blog

 

Theblogreaders.com, i got lot of information about SFDC