How do i increase the values in a column with percentage increment using MySQL, for example:
ID price
1 500
2 800
3 450
How do i increase the values in price column by 20% using one sql query (MySQL)?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityHow do i increase the values in a column with percentage increment using MySQL, for example:
ID price
1 500
2 800
3 450
How do i increase the values in price column by 20% using one sql query (MySQL)?
Simply calculate 20% of actual price:
update your_table
set price = price + (price * 20.0 / 100.0)
where id = (some condition)
or a shorter way:
update your_table
set price = price * 1.2
where id = (some condition)