0

This question already has an answer here:

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

marked as duplicate by Adrian Larson apex May 15 at 1:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

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];

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