I have the following table:
I want the initial_balance for the second row (transaction_id = 124) to be the final_balance of the first row (transaction_id = 123), but I just can't.
I tried using this code:
UPDATE transactions
SET initial_balance = (SELECT final_balance
FROM transactions
WHERE transaction_type = 1)
WHERE transaction_id = 124
Which when selected just the part in parentheses does return the value from the table, but the whole code when running results in an error:
Error Code: 1093. You can't specify target table 'transactions' for update in FROM clause
Can anyone help me?