[SalesForce] Issue with passing multiple input values to Like clause in SOQL query. Any workaround please

I am trying to run this query in Query Editor but got

"Unknown error parsing query"

Is there any workaround for this?

Select Customer_Name__c From SAP_Customer_Master__c where Customer_Name__c like ('trimax%','thomas%')

Best Answer

You can't do that with a like, you'd need to use OR instead:

Select Customer_Name__c From SAP_Customer_Master__c where Customer_Name__c like 'trimax%' or Customer_Name__c like 'thomas%'

EDIT

Something that I didn't know, that I've only just found out from trying it, is that you can use LIKE with bind variables. So, whereas the SOQL in the OP wouldn't work due to a compilation error, this would:

Set<String> names = new Set<String>{'trimax%', 'thomas%'};
List<SAP_Customer_Master__c> masters = [Select Customer_Name__c 
From SAP_Customer_Master__c 
where Customer_Name__c like :names];
Related Topic