在 DB 的 Prestashop 中使用内部连接更新 SQL

Update SQL with Inner Join in Prestashop in DB

我尝试更新 Prestashop 中的数量 table。我有一个 INNER JOIN 从 table "ps_product_attribute"

获取 upc
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");

我找到了解决方案!

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;