I'm trying to develop a script to update the running total within a table:
update transactions set running_total = (select sum(amount) from transactions t2 where t2.sequence_number <= transactions.sequence_number)
- running_total = the cumulative sum of the amount column
- sequence_number = the order in which transactions occurred: 1,2,3,4,5...
MySQL is expectedly showing error You can't specify target table 'transactions' for update in FROM clause
How can I re-write this script without using variables (i.e., by relying only on joins, etc.)