I'm trying to achieve the following:
When I add into the table Players_goals that player_John has scored 3 player_goals in match_xx - That it doesn't just get inserted into the Players_goals table, but also into the Players table. And if player_John had already scored 2 goals, that it gets updated to 5 (sum).
Please see the tables I'm using below:
Players table
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| player_id | int(4) | NO | PRI | NULL | auto_increment |
| player_name | varchar(45) | NO | MUL | NULL | |
| team_name | varchar(45) | NO | MUL | NULL | |
| player_goals | int(4) | YES | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
Players_goals table
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| player_name | varchar(45) | NO | MUL | NULL | |
| match_id | int(4) | NO | MUL | NULL | |
| goals | int(4) | YES | MUL | NULL | |
+-------------+-------------+------+-----+---------+-------+
How can I make this possible?