Subject | Solution for a redundant join? |
---|---|
Author | Jeff |
Post date | 2012-10-24T17:42:58Z |
The following simple query produces the results below:
SELECT SCHEDULE.DATE_TIME, TEAMS.TEAM FROM SCHEDULE
LEFT JOIN TEAMS ON SCHEDULE.HOME_TEAMID=TEAMS.PRIMARYKEY
***QUERY RESULTS (Showing 'Home Team' Column)***
12/01/2012 TeamA
12/21/2012 TeamB
12/25/2012 TeamC
How do I include the corresponding 'Away Team' column? Please see tables below:
***SCHEDULE TABLE***
PRIMARYKEY HOME_TEAMID AWAY_TEAMID DATE_TIME
1 1 2 12/01/2012
2 2 3 12/21/2012
3 3 1 12/25/2012
***TEAMS TABLE***
PRIMARYKEY TEAM_NAME
1 TeamA
2 TeamB
3 TeamC
Please advise, thank you!
SELECT SCHEDULE.DATE_TIME, TEAMS.TEAM FROM SCHEDULE
LEFT JOIN TEAMS ON SCHEDULE.HOME_TEAMID=TEAMS.PRIMARYKEY
***QUERY RESULTS (Showing 'Home Team' Column)***
12/01/2012 TeamA
12/21/2012 TeamB
12/25/2012 TeamC
How do I include the corresponding 'Away Team' column? Please see tables below:
***SCHEDULE TABLE***
PRIMARYKEY HOME_TEAMID AWAY_TEAMID DATE_TIME
1 1 2 12/01/2012
2 2 3 12/21/2012
3 3 1 12/25/2012
***TEAMS TABLE***
PRIMARYKEY TEAM_NAME
1 TeamA
2 TeamB
3 TeamC
Please advise, thank you!