I'm making a search box in php accessing data from a SOQL salesforce database. So far I have this:
$query = "SELECT Id, FirstName, LastName, Phone From Contact WHERE FirstName = '$var'";
Which works perfectly fine. However, how would I make it so that let's say $var
could be the phone number. So if it doesn't match the First name, search for a match in Phone number, etc.
try this:
$query = "SELECT Id, FirstName, LastName, Phone From Contact WHERE FirstName LIKE '%$var%' OR Phone LIKE '%$var%'";
using LIKE instead of = you can match parts of names, for example searching dav would result in David and Daves both being returned. The % are wildcard place holders.