Hi I have two tables one named Team and the other named Schedule.
The Schedule table has the following attributes: id
, away
, home
, date
... where away and home are foreign keys to the Team table.
The Team table has the following attributes: name
and id
.
My goal is to join Team and Schedule so that schedule.id, away, awayTeamName, home, homeTeamName, date are all in the same query. This is what i have so far
SELECT `GAME_ID` , `AWAY` , TEAM.NAME AS awayName, `HOME`, `LEVEL` ,
`LOCATION` , `DATE`
FROM SCHEDULE
INNER JOIN TEAM ON SCHEDULE.AWAY = TEAM.TEAM_ID
OR SCHEDULE.HOME = TEAM.TEAM_ID
and the output i get is something like this
GAME_ID | AWAY | awayName | HOME | LEVEL | LOCATION | DATE
1 | 2 | name1 | 3 |varsity| @home | 06/22/2015
But I want it to look like this
GAME_ID | AWAY | awayName | HOME | homeName| LEVEL | LOCATION | DATE
1 | 2 | name2 | 3 | name3 |varsity| @home | 06/22/2015
If anybody can help i would appreciate it