# Thread: Alter many cols in table with 1 command (and some maths)

1. Registered User
Join Date
Apr 2004
Posts
12

## 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. Resident Curmudgeon
Join Date
Feb 2004
Location
In front of the computer
Posts
15,579
Can you give us an example showing what you've got now, and what you want to get out of it?

-PatP

3. Registered User
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. Resident Curmudgeon
Join Date
Feb 2004
Location
In front of the computer
Posts
15,579
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. Registered User
Join Date
Apr 2004
Posts
12
came up with this...

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