I am trying to get this query right
foreach(explode(" ", trim($words) ) as $word) $where[] = "LIKE '%$word%'";
$wheresql = implode(" OR ", $where);
$q = "SELECT item_id, name, price, details, img FROM items WHERE (details $wheresql) OR (name $wheresql) OR (description $wheresql)";
$rows = $this->dba->rawSelect($q);
The query looks like this now
SELECT item_id, name, price, details, img
FROM items
WHERE (details LIKE '%someword%' OR LIKE '%someword%')
OR (name LIKE '%someword%' OR LIKE '%someword%')
OR (description LIKE '%someword%' OR LIKE '%someword%')
I am not sure if I have to specify the column for every LIKE or do something else
thanks, Richard
1 Answer