我不断收到错误消息,提示 t.product_id 列未知。 我使用了这段代码:
SELECT
t.product_id as ID,
product_category as Category,
product_name As Product,
product_price as Price,
product_decription as Description,
t.Stats as 'Status',
tblinventory.quantity
FROM tblproduct as t
INNER JOIN tblinventory
on t.product_id = tblinventory.product_id
WHERE
CONCAT(`t.product_id`,`product_category`,`product_name`,`t.Stats`) LIKE '%"2"%'
我似乎无法让它发挥作用。 tblproduct 具有列product_id、product_category、product_name、product_price、product_description 和 stats
而 tblinventory 具有 Product_id 和数量列
最佳答案
在 MySQL 中,`t.product_id` 指的是具有该名称的列 - “t.product_id”,而不是表 t
中的列 product_id
。删除转义字符:
WHERE CONCAT(t.product_id, product_category, product_name, t.Stats) LIKE '%"2"%'
您不需要转义名称,所以不需要。
关于mysql - 如何在多列连接表上进行搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47117940/