我有三张桌子:
products:id,name,brand_id
variants:id,name,product_id
brands:id,name
我获取品牌名称的SQL查询是:
SELECT brands.`name`
FROM brands b
LEFT JOIN products p ON p.brand_id=b.id
LEFT JOIN variants v ON p.id=v.product_id AND v.name='test';
可以吗?
cause [error]: Unknown column 'brands.name' in 'field list'
答案 0 :(得分:3)
使用您为brands
表指定的别名:
SELECT b.`name`