Voeg deze trigger toe aan uw ExpenseTable
CREATE TRIGGER ExpenseSum AFTER INSERT ON ExpenseTable FOR EACH ROW
BEGIN
UPDATE ProjectsTable P
SET ExpenseTotal =
(SELECT SUM(ExpenseAmount) from ExpenseTable
where ExpenseTable.ProjectID= P.ProjectID)
where P.ProjectID = New.ProjectID;
END
Vergeet niet een trigger toe te voegen After Update
en After Delete
om ExpenseTotal bij te werken