Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
marcdd2
Starting Member
2 Posts |
Posted - 2010-04-05 : 20:17:47
|
| I have a table, Games, with Baseball games that includes two columns HomeTeamID and AwayTeamID. I want to use PHP to query the DB and pull the Teams names from a second table, Teams, which has two columns TeamID and TeamName. Is this possible or do I need to create two identical tables, HomeTeams and Away Teams? Can someone help me with what the SQL Select query should be or even better the php line? |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-05 : 20:27:52
|
| [code]SELECT h.TeamName AS HomeTeam, a.TeamName AS AwayTeamFROM Games gINNER JOIN Teams h ON g.HomeTeamID = h.TeamIDINNER JOIN Teams a ON g.AwayTeamID = a.TeamID[/code]There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
marcdd2
Starting Member
2 Posts |
Posted - 2010-04-06 : 18:06:25
|
| Thanks for the solution and head up. Didn't notice that it was MSSQL. |
 |
|
|
|
|
|