...

View Full Version : Increase a column of values by a percentage



togi_one
06-27-2011, 05:00 PM
Hi, I want to increase all the prices in a table by 10%. This is what I use to increase the prices by a simple addition:


UPDATE table_name
SET `Price`= `Price`+10

I am assuming I need to combine an SQL statement with some PHP like this:


$percentage = 10;
$whatever = `Price` - (($percentage/100)*`Price`);

But I do not know how. Can anyone help?

abduraooft
06-27-2011, 05:05 PM
Try
UPDATE table_name
SET `Price`= `Price`*110/100

togi_one
06-29-2011, 12:03 PM
Try
UPDATE table_name
SET `Price`= `Price`*110/100

This works for me. Many Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum