0

My game and team schedule is as follows

DBO.GAME

GameTime  |    HomeTeamID      |    AwayTeamID
===================================================
12:00     |         1          |         2

I want to replace the team values with their corresponding team that exists in another table:

DBO.TEAM

  TeamID     |  TeamName
========================
    1        |  AC Milan
    2        |  Paris

I am using an Access form, I am using a combobox to select the date, and onupdate the list box with the below is filled out fine. I am able to achieve this:

GameTime    |  HomeTeamID  |   AwayTeamID 
===========================================
12:00       |       1      |      2

I am trying to display the TEAM NAME instead of the TeamID

GameTime    |  Home Team   |   Away Team
===========================================
12:00       |   AC Milan   |     Paris

Below is the query I am trying to use.

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

I receive the error:

Syntax error (missing operator) in query expression

I've used this solution as a fix, but it doesn't seem to work.

My Access Game/Team relationship

jarlh
  • 42,561
  • 8
  • 45
  • 63
foreff
  • 33
  • 5

1 Answers1

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;