我有三张桌子:
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'