开发者

Column 'idproduct' in from clause is ambiguous

I have this messy join query using 3 tables:

SELECT p.idproduct, p.name, m.su开发者_运维知识库st, p.desc, pp.p_v
FROM products As p
LEFT JOIN meds As m ON m.idproduct = p.idproduct
NATURAL JOIN products_prices As pp
INNER JOIN suc_products As sp ON sp.idsuc = 'SUC1' AND sp.idproduct = p.idproduct
WHERE p.bars = '1';

I get this error:

Error Code: 1052. Column 'idproduct' in from clause is ambiguous

Need help, please.


Here's a wild guess: your product_prices table has an idproduct column and MySQL is complaining that it doesn't know if it should use m.idproduct or p.idproduct for the join.

Try changing the NATURAL JOIN to an INNER JOIN with an explicit ON condition.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜