I had a query that was working fine before for a
sports project .. basically, 3 tables ..  one stored
goal data, one stored team data, and the other player
data.  To get all the scoring data (player names,
jersey #'s), I left joined to the player table 3
different times (on GOAL, ASSIST1, and ASSIST2).

My problem now is, I've split the player information
up into 2 different tables for other purposes, and
need to pull this information from both, but I would
seemingly have to double the number of left joins to
do it, and I'm not sure if that's even possible now.

The query (broken)

select teams.TEAMID, teams.TEAMNAME, goals.GOALID,
goals.SCORER as GSID, goals.ASSIST1 as GA1ID,
goals.ASSIST2 as GA2ID, goals.PERIOD, goals.TIME,
goals.TYPE, p1.JERSEYNUM as SCORERNUM,
ol_g_u_1.FIRSTNAME as SCORERF, ol_g_u_1.LASTNAME as
SCORERL, p2.JERSEYNUM as ASSIST1NUM,
ol_g_u_2.FIRSTNAME as ASSIST1F, ol_g_u_2.LASTNAME as
ASSIST1L, p3.JERSEYNUM as ASSIST2NUM,
ol_g_u_3.FIRSTNAME as ASSIST2F, ol_g_u_3.LASTNAME as
ASSIST2L FROM ol_global.users, ol_icehockey.teams,
ol_icehockey.goals LEFT JOIN ol_icehockey.players as
p1 ON goals.SCORER = p1.USERNUM LEFT JOIN
ol_icehockey.players as p2 ON goals.ASSIST1 =
p2.USERNUM LEFT JOIN ol_icehockey.players as p3 ON
goals.ASSIST2 = p3.USERNUM where GAMEID = '$GAMEID'
AND teams.TEAMID = '$TEAMID' AND teams.TEAMID =
p1.TEAMID order by PERIOD, TIME DESC


Now, this is obviously broken because ol_g_u_* aren't
defined yet (would be left joins to the users table 3
times) .. due to the situation, I'm not sure if I'm
even using the right kind of joins anymore.  Can
someone offer some help or point me in the right
direction on adding those other joins in there?

Thanks,
Chad




__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to