Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    12

    Exclamation Unanswered: Alter many cols in table with 1 command (and some maths)

    Hi all,

    so i currently have a table with products in it. Each product contains 12 units. The prices i have in my db include some tax at 21%. As a special offer i want to sell a product item(12 units) at the price of 11 units.

    So is there some way i can query the db and tell it to calculate the price of 1 unit and then 11 and then VAT for that 11 and update all prices.

    I would do it on a checkout page but the catalog is db driven so i would like prices to be changed there also.

    Any ideas guys?

    Cheers,
    damalo

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Can you give us an example showing what you've got now, and what you want to get out of it?

    -PatP

  3. #3
    Join Date
    Apr 2004
    Posts
    12
    sure,

    so like so....

    ID Product price
    ------- -------- -------
    1 product1 $120

    The above price is for 12 units with 21% tax included. I want to store a price for 11 of these units. So to get this...

    120 / 12 = 10 (10$ for 1 unit and 21% tax)

    11 units = $10 x 11 = $110

    this new price is then sotred in the db.

    Thanks again!
    damalo

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    That is a lot simpler than what I thought you meant. I'd just multiply by 11.0 / 12 and be done with it.

    -PatP

  5. #5
    Join Date
    Apr 2004
    Posts
    12

    Red face

    came up with this...


    update products set price =( (price / 12) * 11 ) where id = 1;


    looks like its the business!

    Cheers!
    (i think i confused myself there a bit aswell hehe)

    damalo

Posting Permissions

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