我正在努力实现以下目标:
当我添加到 Player_goals 表中时, player_John在match_xx中获得了 3 player_goals - 它不仅被插入到Players_goals表中,而且还被插入到Players 表中。如果 player_John 已经进了 2 个球,它会更新为 5(总和)。
请参阅下面我使用的表格:
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 | |
+-------------+-------------+------+-----+---------+-------+
我怎样才能做到这一点?