function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NinoJoseNinoJose 

HELP! Using Like on Apex Code.

Hi Guys,
 
Can somebody shed some light on me I'm loosing my hair trying to figure out whats the problem in my Apex Code.
 
Im using Like in my SOQL to some some record using a String variable for my like expression.

Example:
 
String myValue = '\'%' + somevalues + '%\';
 
List<Account> = new List<Account>([Select Id, Name from Account where customField like :myvalue]);
 
however it does not return and any row but when I used the Apex Explorer to query the same soql expression it gives the records, same as when I put the value directly in my SOQL query inside the initialization code of the List above.
 
Am I missing something?? Need you feedback guys. Any help will be appreciated.
 
Thanks,
 
 
SuperfellSuperfell
Why do you have a \ in front of the %, that means you're querying for the literal character %, not using it as a wildcard.
NinoJoseNinoJose
Hi Simon,
 
Thanks for the reply. The changes was great and it works!
 
Thanks,
 
Nino