I have two tables "Penalties" and "Players" linked with the key "Player_ID". In the "Penalties" table I have several penalties refering to the same Player_ID and in the table "Players" I have a field "total_penalties" with the sum of the penalties for each Player_ID. I need a trigger that updates the field "total_penalties" for the player_ID concerned each time there is a new penalty entry in the table "Penalties". Any idea?
Does this work?
CREATE TRIGGER update_tot
AFTER INSERT ON Penalties
UPDATE Players
SET total_penalties = total_penalties + :new.penalty_value
Does this work?
CREATE TRIGGER update_tot
AFTER INSERT ON Penalties
UPDATE Players
SET total_penalties = total_penalties + :new.penalty_value