how to update a table using SQL command? (maths)

Discussion in 'MySQL' started by cri8bat, Dec 23, 2010.

  1. #1
    I have a product table with over 1K of data

    there are loads of fields and two of them are item_price and isonsale and what I want to do is select all and add %20 of the current price and select all and make isonsale =1;

    can some tell me the command for this pls.
     
    cri8bat, Dec 23, 2010 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Try the following but backup your data before running this query

    UPDATE table_name SET
    item_price = item_price + (item_price * .2),
    isonsale = 1
    Code (markup):
     
    mwasif, Dec 23, 2010 IP