You need to sign in to do that
Don't have an account?
Database query for "near matches"
Hello folks,
I want to allow users to search for contacts and leads in my app using a custom controller. So far I am able to have users search by the contact's email address using the following query syntax:
List<Contact> contacts = [select name from Contact where email=:email];
What I'm wondering is whether if the user enters a partial email address, will this query also return "similar" results? Is there a LIKE condition I can use as there is in standard SQL?
I'm also interested in applying this to user's names - if the user searches for the name "John", i'd like to return all contacts with the first name John.
Will this sort of syntax do what I want? The documentation on doing database queries from Apex hasn't been very clear.
Thanks!
Hi,
Use following statement.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Chamil's Blog
I hope you are inputting the email and name from a vf page.
If its the case, then you can do this using dynamic formatting query in database.query :
Just an example to clear: