我在两个表中有数据:
tbl_games
具有以下列:
game_id, season, date, home_team, visiting_team,
home_score, visiting score, home_score_half_time, visiting score_half_time
tbl_formation
具有以下列:
game_id, home_formation, home_team, visiting_team, visiting_formation
我想将这些表中的数据附加到game_team
具有以下列的表中:
game_id, team_id, status, end_score, half_score, Formation
home_team
visiting_team
我不想让他们分开,而是让他们都处于team_id
状态,并表明它是某场比赛的主队还是客队。
我正在尝试下面的查询,但它不起作用
INSERT INTO Game_Team ( game_id, Team_ID, End_Score, half_score, Formation )
SELECT G.game_id, G.home_team, G.home_score_half_time, G.home_score, GL.home_formation
FROM tbl_games AS G
INNER JOIN tbl_formation AS GL ON G.game_id = GL.game_id;