Double Dipping
| From: | John Hawkins | Date: | Thu, 21 Feb 2002 08:11:23 +0000 |
| Subject: | Double Dipping | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17112@lists.php.net to get a copy of this message | ||
Sorry for the lack of information in the subject line,
but I didn't know how else to explain it briefly...
Howdy, yet again...
Here's the build up...
I have 2 tables and they look like this:
table: teams
ID
leagueID
divisionID
name
table: games
ID
leagueID
divisionID
team_a
team_b
date
time
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!
Thanks for your help.
John
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com