Thread: Query problem
View Single Post
  #2 (permalink)  
Old August 12th, 2004, 01:11 PM
asinning asinning is offline
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I fixed the problem by specifying a LEFT JOIN for each table relationship. I don't recall why I wasn't doing this before. I think it was because I learned how to write SQL using Access with ASP, where nested SELECTs are allowed. When I migrated to MySQL/PHP, I had to learn a whole new way to write these complex JOINs. At the time I thought I would never get along without nested SELECTs.

Here's my new FROM statement

SELECT * FROM
gameResults LEFT JOIN games ON gameResults.gameID = games.gameID
LEFT JOIN users ON gameResults.userID = users.userID
LEFT JOIN questionResults ON gameResults.userGameEventID = questionResults.userGameEventID
LEFT JOIN questions ON (gameResults.gameID = questions.gameID AND questionResults.quesID = questions.quesID)
WHERE gameResults.gameID = 3
GROUP BY questions.quesID

Reply With Quote