Hello everyone.
I have 2 query statements. I don\'t want to use 2 left join statements because it uses too many resources, but when i don\'t use the 2 left joins I don\'t get the same results. I get all the same except with the left joins I have one more record than in the other statement. Can anyone spot why this is happening. Here are my statements:
This one works:
SELECT ITGame.GameID, ITGame.DivisionID, ITGame.GameDate, ITGame.GameTime,
ITGame.GameHomeTeamID, ITGame.GameVisitorTeamID, ITGame.GameHomeScore,
ITGame.GameVisitorScore,
ITGame.GameRainOut,
ITGame.GameNote, ITGame.FieldID, ITGame.LeagueID, ITGame.GameWinnerHome,
ITGame.GameWinnerVisitor
FROM ITGame LEFT JOIN ITDivision
ON ITGame.DivisionID = ITDivision.DivisionID
LEFT JOIN ITLocation ON ITGame.FieldID=ITLocation.FieldID
WHERE ITDivision.SportID = \'$sportID\'
AND ITGame.LeagueID = \'$leagueID\'
AND (ITGame.GameHomeTeamID = \'$teamID\' OR ITGame.GameVisitorTeamID = \'$teamID\')
AND ITDivision.SeasonID = \'$seasonID\'
ORDER BY ITGame.GameDate, ITGame.GameTime
This one does not work. The only difference I see is the left joins. Would that affect it?
SELECT ITGame.GameID, ITGame.DivisionID, ITGame.GameDate, ITGame.GameTime,
ITGame.GameHomeTeamID, ITGame.GameVisitorTeamID, ITGame.GameHomeScore,
ITGame.GameVisitorScore,
ITGame.GameRainOut,
ITGame.GameNote, ITGame.FieldID, ITGame.LeagueID, ITGame.GameWinnerHome,
ITGame.GameWinnerVisitor
FROM ITGame, ITDivision, ITLocation WHERE ITGame.DivisionID=ITDivision.DivisionID AND ITGame.FieldID=ITLocation.FieldID AND ITDivision.SportID = \'$sportID\' AND ITGame.LeagueID = \'$leagueID\' AND (ITGame.GameHomeTeamID = \'$teamID\' OR ITGame.GameVisitorTeamID = \'$teamID\') AND ITDivision.SeasonID = \'$seasonID\' ORDER BY ITGame.GameDate, ITGame.GameTime
Thanks for your time. Any help is greatly appreciated.