我尝试更新Prestashop表中的数量。我有一个INNER JOIN来从表中获取upc" ps_product_attribute"
UPDATE ps_stock_available
SET ps_stock_available.quantity = ps_stock_available.quantity - 1
INNER JOIN ps_product_attribute ON ps_product_attribute.id_product_attribute = ps_stock_available.id_product_attribute
WHERE ps_product_attribute.ups = 01900000118;
但我总是有这个错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'INNER
JOIN ps_product_attribute ON ps_product_attribute.id_product_attribute = p' at line 3
有人可以帮帮我吗?我尝试了很多不同的东西。
编辑: 我尝试了另一种方式:
使用SELECT,我可以从ps_stock_available获得id_product_attribute。
SELECT id_product_attribute
FROM ps_product_attribute
WHERE upc in ("01900000118","01900000119");
是否可以使用结果进行更新?
UPDATE ps_stock_available
SET quantity = quantity-1
WHERE id_product_attribute in ("result1", "result2");
答案 0 :(得分:0)
我找到了解决方案!
SELECT sa.id_product, sa.id_product_attribute, sa.quantity, pa.upc
FROM ps_stock_available AS sa
LEFT OUTER JOIN ps_product_attribute AS pa ON pa.id_product_attribute = sa.id_product_attribute
WHERE sa.id_product = 140;