For my site, I’ve created a search page where users can search for the phone model name or the manufacturers name — but not both. Users can type “apple” and get a list of all Apple’s phones, or they can type “3g” and get a list of all the phones with “3g” in their name.
But, if a user types, “apple iphone” or “htc evo”, they get zero results because the manufacturer name and the phone name are in two different columns.
This is my search statement:
$sql = "SELECT
o.id,
o.label,
o.manufacture_id,
o.buyback_price,
o.image_path,
u.id,
u.label
FROM phone_models as o
LEFT JOIN manufactures as u ON o.manufacture_id = u.id
WHERE o.label like \"%$searchTerm%\" OR u.label like \"%$searchTerm%\"
order by o.label";
Is there a way to create a new column that has both data from u.label AND o.label?
Thanks!
try:
But replace spaces in your $searchTerm with %: