mysqlsql-updateprestashop-1.7multistore

MYSQL Prestashop 1.7 update price multistore


How do I run it for all rows of a given product id and shop id:

One table: ps_product_shop

id_product price id_shop
1 1 1
1 25 3
2 2 1
2 50 3

THX

For one line: UPDATE ps_product_shop SET price=(SELECT price FROM ps_product_shop WHERE id_product = '1' AND id_shop = '1')*25 WHERE (id_product='1') AND (id_shop='3');

I tried but it doesn't work: UPDATE ps_product_shop SET price=(SELECT price FROM ps_product_shop WHERE id_product = ps_product_shop.id_product AND id_shop = '1')*25 WHERE ps_product_shop.id_product IN (SELECT price FROM ps_product_shop WHERE id_product = ps_product_shop.id_product AND id_shop = '3');


Solution

  • I already figured it out, maybe it will help someone:

    UPDATE ps_product_shop AS sk SET 
    price=(SELECT price FROM ps_product_shop
    WHERE id_product = sk.id_product AND id_shop = '1')*27 WHERE (sk.id_shop='3');
    

    for all lines sk.id_shop='3'