tags:

views:

24

answers:

1

Hi,

I know that a database is used to stre data in, but I have a little problem. I have a a column with prices for my online store, now I want to change all the prices with a certain a som of 1.5

example:

Normal the column prices has a value for ie: 1,95, this should be changed to 2,04 (round on 2 decimals)

What can I do?

+2  A: 

Use a query tool, like the MySQL command line client, the Query browser, or even phpMyAdmin and issue this statement

UPDATE product 
SET    price = ROUND(price + 1.5, 2)

assuming your table is called product and your column is called price

Roland Bouman
Great thanks! I assume it's a one time statement, it won't be remebered with next inserts right?
Chris
Yes. This operation modifies whatever is inside the table now. But running this statement again though will perform the math and the assignment again of course.
Roland Bouman
yes, this means that allready assigned modifications wil be modified again right?
Chris
Yes. Whenever you execute this statement, all rows will be modified, changing their price to whatever is the current price plus 1.5. "All rows" includes any rows that were previously modified by this statement. In a normal RDBMS rows only remember their current state - they know nothing about what brought about their current state
Roland Bouman