列“idproduct” in from 子句不明确
我有一个使用 3 个表的混乱连接查询:
SELECT p.idproduct, p.name, m.sust, 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';
我收到此错误:
Error Code: 1052. Column 'idproduct' in from clause is ambiguous
需要帮助,请。
I have this messy join query using 3 tables:
SELECT p.idproduct, p.name, m.sust, 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个疯狂的猜测:您的
product_prices
表有一个idproduct
列,并且 MySQL 抱怨它不知道是否应该使用m.idproduct
或用于连接的p.idproduct
。尝试将 NATURAL JOIN 更改为具有显式 ON 条件的 INNER JOIN。
Here's a wild guess: your
product_prices
table has anidproduct
column and MySQL is complaining that it doesn't know if it should usem.idproduct
orp.idproduct
for the join.Try changing the NATURAL JOIN to an INNER JOIN with an explicit ON condition.