Search code examples
mysqljoinsql-like

#1064 - SQL join 2 table issue


I am not familiar with using sql. May I know what the problem with this query? The code is as follows:

SELECT * 
FROM `products` 
JOIN 'cats' ON products.`cat_id` = cats.'id'
WHERE products.pro_name LIKE 'cats.name';

Solution

  • Try this:

    SELECT * FROM products 
    JOIN cats 
    ON products.cat_id = cats.id 
    WHERE products.pro_name LIKE '%'+cats.name+'%'