LEFT JOIN query help

From: Date: Sun, 18 Jul 2010 17:20:37 +0000
Subject: LEFT JOIN query help
Groups: php.db 
Request: Send a blank email to php-db+get-47267@lists.php.net to get a copy of this message
I am writing a Bible trivia application. I am trying to write the mySQL query that will select the next question reference number and the current question is answered. The value I want to retrieve It is in the field: verse_of_the_day_Bible_trivia.reference I don't think I have my LEFT JOIN's right. When I take away the "WHERE" clause only the records the user has answered are selected. Then they are being eliminated with the WHERE clause. I am hoping the results join the 3 tables together --- really wide --- with the user profile on the left hand side and then the question is the middle and if the user has answered it then this record on the right hand side, otherwise the fields are NULL. Does this make sense? Ron SELECT verse_of_the_day_Bible_trivia.reference FROM ( my_Bible_trivia_knowledge_profile LEFT JOIN my_Bible_trivia_knowledge_questions_answered ON my_Bible_trivia_knowledge_profile.reference = my_Bible_trivia_knowledge_questions_answered.my_Bible_trivia_knowledge_profile_reference ) LEFT JOIN verse_of_the_day_Bible_trivia ON verse_of_the_day_Bible_trivia.reference = my_Bible_trivia_knowledge_questions_answered.verse_of_the_day_Bible_trivia_reference WHERE my_Bible_trivia_knowledge_questions_answered.my_Bible_trivia_knowledge_profile_reference <> $user_reference AND my_Bible_trivia_knowledge_questions_answered.score IS NULL AND verse_of_the_day_Bible_trivia.live =1 ORDER BY RAND() LIMIT 1

« previous php.db (#47267) next »