我的比赛和球队时间表如下
DBO.GAME
GameTime | HomeTeamID | AwayTeamID
===================================================
12:00 | 1 | 2
我想将团队价值替换为另一个表中存在的相应团队:
DBO.TEAM
TeamID | TeamName
========================
1 | AC Milan
2 | Paris
我正在使用Access表单,我使用组合框来选择日期,并且更新列表框,下面填写正常。 我能够做到这一点:
GameTime | HomeTeamID | AwayTeamID
===========================================
12:00 | 1 | 2
我正在尝试显示TEAM NAME而不是TeamID
GameTime | Home Team | Away Team
===========================================
12:00 | AC Milan | Paris
以下是我尝试使用的查询。
SELECT g.GameTime, t.TeamName as 'Home Team' , t.TeamName as 'Away Team'
FROM GAME AS g
INNER JOIN TEAM AS t ON g.HomeTeamID = t.TeamID
INNER JOIN TEAM AS t ON g.AwayTeamID = t.TeamID
我收到错误:
Syntax error (missing operator) in query expression
我已经使用this解决方案作为修复,但它似乎无法正常工作。
答案 0 :(得分:0)
SELECT
g.GameTime,
t1.TeamName as 'Home Team',
t2.TeamName as 'Away Team'
FROM
GAME g
INNER JOIN TEAM AS t1 ON g.HomeTeamID = t1.TeamID
INNER JOIN TEAM AS t2 ON g.AwayTeamID = t2.TeamID;