我需要将数据从 2 个表追加到 Access 中的现有表 [英] I need to append data to an existing table in Access from 2 tables

查看:20
本文介绍了我需要将数据从 2 个表追加到 Access 中的现有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表中的数据:

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 表中:

I would like to append data from these tables into a game_team table that has the following columns:

game_id, team_id, status, end_score, half_score, Formation

与其将 home_team visiting_team 分开,我希望将它们全部放在 team_id 下,并且状态表明它是主队还是主队某场比赛的客队.

Instead of separating out home_team visiting_team I would like to have them all under team_id and status indicating whether it was a home team or a visiting team for a certain game.

我正在试验下面的查询,但没有用

I was experimenting with the query below but it did not work

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;

推荐答案

试试这个

INSERT INTO Game_Team ( game_id, Team_ID, End_Score, half_score, Formation )
SELECT G.game_id, G.home_team & ' ' & G.visiting_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;

这篇关于我需要将数据从 2 个表追加到 Access 中的现有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆