[eluser]mandril[/eluser]
Hi everyone, i have a problem with LIKE.. it seems to not be working properly...
Im developing an e-commerce and need to get the related products, for that reason the table product has a field called : tags.
Here is my method... that returns nothing, and if i remove the p1.id != p2.id it returns the product itself.. quite logic.
Code:
public function getRelatedProducts($idProd)
{
$query = $this->db->query("SELECT p1.id, p1.name FROM product p1, product p2 WHERE p1.id='".$idProd."' AND p1.id != p2.id AND p1.tags LIKE p2.tags");
return $query;
}
Ok help me analyze step by step..
I need to grab the name and the id of the product so...
SELECT p1.id, p1.name seems fine
I need to compare a product with other products..
FROM product p1, product p2 seems fine
Now i need that one of the product is the one the customer is viewing .. that variable is $idProd
WHERE p1.id='".$idProd."' AND seems fine
I dont need to get the name of the product itself as a related product

so..
p1.id != p2.id seems fine
I have to get similar tags.. so i use LIKE
AND p1.tags LIKE p2.tags is this working ?
a product has a tag like this: cellphone sony ericsson cam
and i put a similar tag to other product: cellphone motorola cam
AND I GET NO RESULT....
Thnx for your help