Update quantity from Prestashop Database

I have a little problem to UPDATE the Prestashop database. I try to update the quantity from ps_stock_available. I have 2 quantity to update. My INNER JOIN work.

id_product   id_product_attribute   upc           quantity
140          263                    90100014017   665

but with the upc, I also need to get the id_product to update an other id_product_attribute with 0 :

id_product   id_product_attribute   upc           quantity
140          0                      90100014017   675

SQL:

UPDATE ps_stock_available AS s
INNER JOIN ps_product_attribute AS ps ON ps.id_product_attribute = s.id_product_attribute
INNER JOIN ps_product AS p ON p.id_product = ps.id_product
SET s.quantity = s.quantity-1
WHERE ps.upc = 90100014017

It's work to update the first quantity, but I don'y know how to update the second quantity. Someone can help me?

Upvotes: 0

Views: 2406

Answers (1)

I found the solution !

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;

Upvotes: 1

Related Questions