skip to Main Content

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’);

2

Answers


  1. Chosen as BEST ANSWER

    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'


  2. Something like this?

    UPDATE ps_product p, ps_product_shop ps 
    SET p.price = p.price*25, ps.price = ps.price*25
    WHERE p.id_product = 1 AND ps.id_product = 1 AND ps.id_shop = 2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search