Are there any workarounds for creating a query using the LIKE operator on a set of strings? I would like to create a new object(Exclusions) which would house records that have a field for keywords that should be excluded from a query. I would like to have the method query for the exclusion records, and then exclude the cases where the subject matches any of the keywords the query brings back.

The only workaround I can think of would be using a string query, then looping through exclusion results and adding additional OR clauses with a single LIKE operator for each exclusion record. I feel like there may be SOQL limits I may run into here (string length of query depending on how many exclusion records)?


1 Answer 1


Yes, you can use LIKE with IN

This is how you can do it with Set<String>

Set<string> setNames= Set<string>();
List<Accounts> lstAccounts = [select id, name from Account where name like :setNames];

Not the answer you're looking for? Browse other questions tagged .