Is there a way to do Like against a list of Values?

Is there a way to mix LIKE operator with IN ?
Something Like

SELECT Id FROM Account WHERE Name LIKE IN:nameList

Where nameList is list of String?
Is this is possible ?
(I can make a dynamic query by doing OR with all the elements, but was looking for a more elegant way to do this)

Answer

No, but you can query like this which does the same thing as what you’re trying to do:

String[] filters = new String[]{'acme%','ib%'};
List<Accounts> accs = [select id, name from Account where name like :filters];

Attribution
Source : Link , Question Author : Avidev9 , Answer Author : drakored

Leave a Comment