fetch data from table and write into another
I've got two database tables.. named actual_prices and original_prices.
What I want to do is fetch all prices from within the original_prices table (field: o_price), and add some value to it.. then I want the new calculated price written into the actual_prices table (field: price).
The structure of both tables is:
original_prices: p_id, description, o_price
actual_prices: P_id, description, price
(where P_id is the primary field).
Now let's say I've got this example data within orginal_prices:
1, test product, 20.00
2, another product, 2.00
3, not another test, 11.00
I want to add $5.00 to each product, and store the new price in table actual_prices only. So the example data within actual_prices should look like this:
1, test product, 25.00
2, another product, 7.00
3, not another test, 16.00
I know the sql update statement, but how can I loop through all records within original prices and update the actual_prices ?