Trying to create a field in a table that will get the old value of another field. My table is very similar to this:
------------ -------------------- ------------------------
| id int(10) | price decimal(5,2) | price_old decimal(5,2) |
----------------------------------------------------------
What I am trying to get is the value of price
field to get copied in price_old
field ON UPDATE
of the current record.
Is it possible to achieve this only with mysql?
PS: The data contained in that cell is not critical. The usage is to store the previous price of a item and after to be able to show how it changed. I will only need the last value, not the full history of the table entry. (My MySQL server is 5.0, if this matters)
Use triggers on update rule. There set value of price to price_old