[SalesForce] Using In Clause with multi pick list

I'm trying to query some data in access from a multi pick-list using this query:

SELECT Contact.Account.Name, Contact.LastName, Contact.FirstName, Contact.Email, Contact.Title, Contact.Summit_History__c
FROM Contact
WHERE Contact.Summit_History__c in ('OOTS-2014-US-Speaker')

The problem is that it's only returning rows where the Summit_History is just "OOTS-2014-US-Speaker". Is there a way to do a fuzzy search, so that I'm returning rows that have this as at least one of the options, but not exclusively that option?

Best Answer

You need to use the INCLUDES

SELECT Contact.Account.Name, Contact.LastName, Contact.FirstName, Contact.Email, Contact.Title, Contact.Summit_History__c
FROM Contact
WHERE Contact.Summit_History__c INCLUDES ('OOTS-2014-US-Speaker','myValue2','myValue3')

This will return any results that have at least one of the values in the INCLUDES filter. if you need to filter for specific combinations, you'll ned to use this format

SELECT Contact.Account.Name, Contact.LastName, Contact.FirstName, Contact.Email, Contact.Title, Contact.Summit_History__c
FROM Contact
WHERE Contact.Summit_History__c INCLUDES ('OOTS-2014-US-Speaker','myValue2; myValue3')

This will yield any results that contain 'OOTS-2014-US-Speaker' OR ('myValue2' AND 'myValue3')

Related Topic