Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Increase a column of values by a percentage

    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:

    Code:
    UPDATE table_name
    SET `Price`= `Price`+10
    I am assuming I need to combine an SQL statement with some PHP like this:

    PHP Code:
    $percentage 10;
    $whatever = `Price` - (($percentage/100)*`Price`); 
    But I do not know how. Can anyone help?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try
    Code:
    UPDATE table_name
    SET `Price`= `Price`*110/100
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile [RESOLVED] Increase a column of values by a percentage

    Quote Originally Posted by abduraooft View Post
    Try
    Code:
    UPDATE table_name
    SET `Price`= `Price`*110/100
    This works for me. Many Thanks.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •