SQL for price updates

Ask the community for help and support.
Post Reply
Yahalimu
Posts: 22
Joined: Mon Oct 26, 2020 1:27 pm
Has thanked: 3 times

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)
User avatar
zipurman
PhoenixCart Developer
PhoenixCart Developer
Posts: 470
Joined: Tue Oct 13, 2020 5:20 pm
Has thanked: 84 times
Been thanked: 147 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
aka Preston Lord
-----------
Happy to help where I can ;)

https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
Image
Post Reply