I do not understand how to update a table from another table after a table has been modified.
I have a table with 3 columns like id(INT), distname(VARCHAR)UNIQUE and score(INT), and I have another table with id(INT), name(VARCHAR), points(INT), penalizes(INT)
each time a name gets some points they go to the second table.
I want to write a routine that makes the following
SELECT DISTINCT(name) AS distname, SELECT(SUM(points)-SUM(penalizes)) AS score FROM table2
and updates the table1 each time before someone makes a select on table1, or each time someone enters data into table2
How would this look like?