5 messages in com.mysql.lists.win32Re: Help out a newbie
FromSent OnAttachments
Douglas Otwell22 Feb 2002 07:55 
Peter22 Feb 2002 08:41 
Douglas Otwell22 Feb 2002 11:46 
Peter22 Feb 2002 17:38 
Joel Nelson22 Feb 2002 19:16 
Subject:Re: Help out a newbie
From:Douglas Otwell (dko6@yahoo.com)
Date:02/22/2002 11:46:28 AM
List:com.mysql.lists.win32

I'm sorry, I wasn't clear. I want results only for a single student, say studentID = 2. But if I put that in the WHERE clause in your example, I won't get results for quizes NOT taken by #2, because somebody else DID take that quiz. See my dilemma?

Hi

SELECT student.studentID, student.studentname, quiz.quizID, quiz.answ1, quiz.answ2 FROM student LEFT JOIN quiz ON (studentID = quizID) ORDER BY student.studentID

... give You all fields availbale without temp. tables.

----- Original Message ----- From: "Douglas Otwell" <dko6@yahoo.com> To: <win@lists.mysql.com> Sent: Friday, February 22, 2002 4:56 PM Subject: Help out a newbie

Ok, this may be a general SQL question. I need to do a left-outer join

on

a

table and a dynamic query. For example, I have a "quiz" table, and an "answer" table containing quiz answers for all students. I need a result set containing every row in "quiz" with answers for a specific student, with nulls for quizes that the student has not taken yet. I guess I could create a temporary table "SELECT * FROM answers WHERE answers.student = somebody" and then left-outer join that temporary table with "quizes", but I was wondering if there were a more efficient/elegant way to do this.

Thanks for any help, Douglas