I'm trying to update the remaining amount of money on different debit cards. I have the 2 following tables : Cards and Transactions. I would like my result to be:
Number|Initial_Amount|Remaining_Amount T_ID|T_Date|Credit_Card|Amount
---------------------------------------- ---------------------------------
123| 1000| 820 1| 05/02| 123| 100
456| 200| 150 2| 06/02| 456| 50
3| 06/02| 123| 80
I tried to run the following Query :
UPDATE Credit_Cards
SET Credit_Cards.Remaining_Amount =( Credit_Cards.Initial_Amount-(
SELECT SUM(T.Amount)
FROM Transactions AS T
WHERE T.Credit_Card = Credit_Cards.Number));
But I get the following error : "Operation must use an updateable query"
What can be the problem ? I saw many answers about JOINs but not using one here so I don't understand...