Correct way to record multiple parameter lookups
Belove is my search term, which works great if I want any of the search value passed through, but what if I want an exact match for a specific value?
I can use the operator AND
, but that will increase the number of lines, for example how can I write a query if I want a particular location
match, pls can someone help me with a better search query
$sql = "SELECT * ";
$sql .= "FROM js_projects WHERE ";
$sql .= "jsp_title LIKE '%" . $valToSearch . "%' ";
$sql .= "OR jsp_nature LIKE '%" . $nature . "%' ";
$sql .= "OR jsp_etype LIKE '%" . $etype . "%' ";
$sql .= "OR jsp_location LIKE '%" . $location . "%' ";
$sql .= "OR jsp_date LIKE '%" . $jobdate . "%' ";
Edit
Suppose I have a value for
-
valtosearch, location, jobdate, etype and I want an exact match for all these values,
-
or I can have any two of these values ββand I want them to match exactly,
-
or I can get any of these values ββand I want it to be accurate.
So how can I write a query for all these possibilities?
source to share