> Sorry for the lack of information in the subject line,
> but I didn't know how else to explain it briefly...
=don't be sorry, re-word it!
> I have 2 tables and they look like this:
> There are 2 other tables involved, but they don't come
> into play for this portion of the problem so I won't
> bother you with the details.
> Some sample data may look like this:
> Table: teams
> | ID | leagueID | divisionID | name |
> | 11 | 1 | 5 | Dodgers |
> | 12 | 1 | 5 | Cobras |
> | 13 | 1 | 5 | Bombers |
> Table: games
> | ID | leagueID | divisionID | hometeamID | awayteamID
> | gamedate | gametime |
> | 1 | 1 | 1 | 12 | 13
> | 2002-02-21 | 15:30:00 |
> | 2 | 1 | 1 | 11 | 12
> | 2002-02-26 | 15:30:00 |
> Here's the issue...
> I want to be able to have it pull in the name for each
> of the teams (home and away) from the database. My
> existing query looks like the following:
> (note: $leagueID = 1 in the following line)
> SELECT gdate, gtime, divisions.name as division,
> teams.name as teama, teams.name as teamb FROM
> divisions, teams, games WHERE games.leagueID =
> '$leagueID' group by gamedate, gametime
> This has gotten me close, but, not over the hump.
> As always, I hope I have explained this well enough!
The missing item that might have been helpful is a sample output of what you have so
far. I'll guess that it's
gdate, gtime, division, teama, teamb
-02-21 15:30 1 blank blank
If you substitute/add hometeamID and awayteamID in the resultset (purely for debugging
purposes) then you should
see the IDs 12 and 13 appearing, but still no team names under teama or teamb.
You probably know that you are missing the join between games and teams. There is no
reason why you cannot have
two joins - "double dipping". Did you try it?
WHERE...teams.ID=hometeamID AND teams.ID=awayteamID
NB the above does not imply (as some might at first think) that hometeamID would have
to equal awayteamID for
this to work, the two ANDs/the two joins are independently arranged.
Let us know how you get on!
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php