Birleyici
Birleyici

Reputation: 43

sql query to update all product prices

I want to update the regular_price and sale price values ​​of all simple and variation products with a SQL query. I need to round the price when updating. to multiples of 5. example:

125.35 - 125.00,
129.10 - 130.00,
128.00 - 130.00,
127.00 - 125.00

Upvotes: 0

Views: 995

Answers (2)

Hadi Rajabi
Hadi Rajabi

Reputation: 62

Use this if you want .00 decimal number:

/* Replace 2 with your decimal count number */
UPDATE tablename SET regular_price = ROUND(ROUND(regular_price /5) * 5, 2)

Upvotes: 0

IT goldman
IT goldman

Reputation: 19485

UPDATE table SET price = ROUND(price /5) * 5

Upvotes: 2

Related Questions