Example keyword search “CAR WASH”
car wash have to be appear in the string regardless of position
The searchable string can be very long and the query should search for these keywords together and separately. There can be more than two keywords.
$query="SELECT * FROM TABLE WHERE zip LIKE'abc'";
$key= explode(" ", $keywords);
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle LIKE '".$key[$i]." %' OR dealTitle LIKE '% ".$key[$i]." %' OR dealTitle LIKE '% ".$key[$i]." ')";
}
However, the query is returning those records containing “car” or “wash”.
If I use “car wash” both words need to appear at least once. Any suggestion on how to modify my search to take this condition into account?
Should use AND
EDITED: