I'm trying to use LIKE in my dynamic SOQL with a list.
My code:
SELECT Id, Name FROM Account WHERE Name LIKE ('%somevalue%', '%testvalue%')
I can't and I don't want to use variable reference for the list so I constructed this string.
The error when I try to run the above query:
expecting a colon, found '('
And When I add a colon this is the error that I get:
System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL.
How can I achieve this without using a variable reference?
The only other way I could think of is:
SELECT Id, Name FROM Account WHERE Name LIKE '%somevalue%' OR Name LIKE '%testvalue%'
With the above way, there's chance of hitting query string character limit. Is there a better way to do this?
LIKEagainst a bound collection but there isn't direct syntax support for the same query. – Daniel Ballinger Apr 25 '18 at 10:33List<String> s = new List<String>{'Burlington%','%plc'}; String query = 'select id, name from Account where name like: s'; List<Account> a = Database.query(query);– Mr.Frodo Apr 25 '18 at 17:47