0

I have a table with columns: [id, value] (id = integer PK, value= integer). I'd like to update the value column for a given id, retrieveing the old value. Is posible to do this in a single query? or I need to make a query and then an insert?

Thanks in advance

Addev
  • 31,819
  • 51
  • 183
  • 302
  • Possible duplicate of (http://stackoverflow.com/questions/562693/mysql-update-and-select-in-one-pass) Short answer is it can't really be done with a single query, but you can create procedure to do it, allowing a single query to accomplish the same. – Kibbee Aug 20 '11 at 02:16

1 Answers1

2

You could create a trigger that puts the old value in another table (or even into another column of the current table). Other than that, you'd need to do two queries.

Doug Kress
  • 3,537
  • 1
  • 13
  • 19