I have a table which includes id and name
--- -----
id name
--- -----
1 pete
My scenarios looks like this
$sql
If you are updating one row and you want the previous name, you can use variables:
set @prevname = '';
update table_name
set name = if(@prevname := name, 'Alan', 'Alan')
where id = 1;
select @prevname;
However, I suspect that you really want a slowly changing dimension, and update
is not the right operation.