Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Does SOQL support wild card?
Select Name, Email, Phone From Lead where Name like %searchText%
does it work for the SOQL command above? please advice.
thanks
Yes, Select Name, Email, Phone From Lead where Name like '%searchText%'
See the SOQL section of the API docs.
thanks for your reply.
results = (List<Lead>) [Select Name, Email, Phone From Lead where Name like '%searchText%'];
I just tried the SOQL command above in my Apex code but it does not seem to work. Is it correct syntax?
I entered Tom in the search input box and it returned nothing. I know for sure there's a name Tom James in
the Lead. Any ideas?
Paul
yes that is my exact code. I'm not sure about the wild card SOQL syntax. If you do please help
with example.
// you have to set the searchText variable to whatever it is you're tying to find from whereever its coming from.
String fnd = '%' + searchText + '%';
List<Lead> = [select id, name from Lead where name like :fnd];
Thanks so much. it works.
You saved me hours of research.
Have a great day!
Yes, Select Name, Email, Phone From Lead where Name like '%searchText%'
See the SOQL section of the API docs.
thanks for your reply.
results = (List<Lead>) [Select Name, Email, Phone From Lead where Name like '%searchText%'];
I just tried the SOQL command above in my Apex code but it does not seem to work. Is it correct syntax?
I entered Tom in the search input box and it returned nothing. I know for sure there's a name Tom James in
the Lead. Any ideas?
thanks
Paul
yes that is my exact code. I'm not sure about the wild card SOQL syntax. If you do please help
with example.
thanks
// you have to set the searchText variable to whatever it is you're tying to find from whereever its coming from.
String fnd = '%' + searchText + '%';
List<Lead> = [select id, name from Lead where name like :fnd];
Thanks so much. it works.
You saved me hours of research.
Have a great day!
Paul