简体   繁体   中英

#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';

Try this:

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

Try this

SELECT * FROM products prod,cats cat ON 
products.cat_id = cat.id where products.pro_name LIKE '%'+cat.name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM