[thelist] Re: mySQL query

Tab Alleman Tab.Alleman at MetroGuide.com
Fri Jun 11 10:13:10 CDT 2004


Tom Dell'Aringa wrote:

> SELECT
>   games.gamesdate, games.a1, games.a2, games.a3, games.b1, games.b2,
> games.b3,
>   games.teamAID, games.teamBID, a.name, b.name
> FROM
>   games
> INNER JOIN
>   team a ON games.teamAID = a.teamID
> INNER JOIN
>   team b ON games.teamBID = b.teamID
> 
> I've never been good using aliases as you can probably see. Anyway,
> this gives me only ONE team name in BOTH places... I can't seem to
> get both team names...

Not that this will necessarily solve your problem, but you might want to
alias the two team names in your select list.. Otherwise you've got two
columns in your resultset called "name" (the fact that one was prefixed
with "a" and the other with "b" don't translate to the resultset).
Soooo...

> SELECT
>   games.gamesdate, games.a1, games.a2, games.a3, games.b1, games.b2,
> games.b3,
>   games.teamAID, games.teamBID, a.name AS NameTeamA, b.name AS
NameTeamB
                                         ^^^^^^^^^^^^
^^^^^^^^^^^^


More information about the thelist mailing list