0

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)?

2

Yes, you can use LIKE with IN

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

Set<string> setNames= Set<string>();
setNames.add('sample%');
setNames.add('testaccount%');
List<Accounts> lstAccounts = [select id, name from Account where name like :setNames];
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.