[英]Column 'idproduct' in from clause is ambiguous
I have this messy join query using 3 tables: 我有使用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';
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. 这是一个疯狂的猜测:您的
product_prices
表中有一个idproduct
列,而MySQL抱怨说它不知道应该为连接使用m.idproduct
还是p.idproduct
。
Try changing the NATURAL JOIN to an INNER JOIN with an explicit ON condition. 尝试将NATURAL JOIN更改为具有显式ON条件的INNER JOIN。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.