Is is possible to use wildcards in where statements on multi-select fields

I tried a simple

Select Id, Name from Positions_c where Industry_c includes(:selectedIndustry)

this works

but if i want to pass a wildcard in with :selectedIndustry it breaks?

  • What are you using for your value of selectedIndustry in this example? And what is the error it's failing with? I was able to get this working in the developer console, so it may just be that you're passing in something unexpected. – JCD Jul 23 '13 at 12:35
  • I'm trying to get it work just passing in a wildcard like '%' and nothing else – Keith Mancuso Jul 23 '13 at 15:07
  • 2
    To my knowledge you can only use the wildcard with a like expression. includes is a different story, and you're pretty limited with what you can do with it at this point. salesforce.com/us/developer/docs/officetoolkit/Content/… – JCD Jul 23 '13 at 16:18

You have to combine the use of LIKE and % in collections.

You have to populate the sets with % first and then use LIKE to query.


    List<Account> accList = [SELECT Id FROM Account WHERE Name LIKE :setAccNames];

Here's more on this:



I don,t think that you can use wild card with the include tag in SOQL but you can use the query in two ways :

1. Industry_c Like :'%'+selectedIndustry+'%'

2.Set<String> industryValues = new Set<String>{'%selectedIndustry'};

 Select Id, Name from Positions_c where Industry_c includes(:industryValues)

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.