Page 1 of 1

SQL for price updates

Posted: Sun Jun 13, 2021 3:52 pm
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)

Re: SQL for price updates

Posted: Sun Jun 13, 2021 5:03 pm
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);