Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

query to increase price value by 15% in selected rows

Tags:

sql

mysql

I need to increase price by 15% in some rows of a table named my_products, based on the refresh_time of the product itself.

I don't know how to write this query, I was trying:

UPDATE my_products SET price = (price + 15%) WHERE refresh_time like "%2013%"

But this doesn't work.

like image 384
ol30cean0 Avatar asked Dec 09 '22 08:12

ol30cean0


1 Answers

UPDATE my_products SET price = (price * 1.15) WHERE refresh_time like "%2013%"

Just multiply the amount times 1.15. The 1 keeps the original value and the .15 adds the additional 15%.

like image 133
John Conde Avatar answered Dec 11 '22 10:12

John Conde