SQL syntax question about UPDATE. It would be much easier to ask the question by giving example below:
**Payments Table**
ID user_id payment_due payment_made
1 3 10.0 5.0
1 3 10.0 10.0
1 9 20.0 20.0
**Balance Table**
ID user_id current_balance
1 3 ???
2 9 ???
Let say I would like to update the current balance for specific user. What would be the correct and efficient SQL syntax to add all payment dues and subtract it from all payment made for a specific user?
In this case, current_balance for user '3' is 5.0 and for user '9' is 0.0