SQL for price updates

Open to all! Ask other shopowners for help.
Post Reply
Yahalimu
Member
Posts: 29
Joined: Mon Oct 26, 2020 1:27 pm
Phoenix Version: v1.0.5.0
Has thanked: 4 times
Been thanked: 1 time

SQL for price updates

Post by Yahalimu »

Hi,

To increase all products by certain percentage per manufacturer in PhpMyAdmin is simple and has been covered before:
eg.

update `products` set `products_price` = (`products_price` * '1.05') WHERE `manufacturers_id` = '23';

Alas this only fully works with un-attributed products.
'products_attributes' does not have the manufacturer_id as a column as its in 'products'.

Any suggestions on how the above SQL query be changed, so as to also increase the attributes by the set percentage? (of the manufacturers products)


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: SQL for price updates

Post by zipurman »

Make sure you backup your database first, but the following should work:

update products_attributes SET options_values_price = (options_values_price * 1.05) WHERE products_id IN (SELECT products_id FROM products WHERE manufacturers_id = 23);
zipurman
-----------


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply