> SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE > results.id_test IS NULL AND id_student=".$user exams.id_test=results.id_test results.id_test IS NULL think those are preventing this from happening. Wouldn't you want this Results.id_student IS NULL Since if the student didn't take the test there would not be a record for it and the outer join would add that. Then probably an and for id_test=$var. for a specific test. GL Scott -----Original Message----- From: Barry [mailto:barry@xxxxxxxxxxxxxx] Sent: Tuesday, February 21, 2006 7:57 AM To: php-general@xxxxxxxxxxxxx Subject: Re: Help with query Ing. Tomás Liendo wrote: > Hi I need the students that didn't take an exam. The tables: > > exams(id_test, title, desciption, ....) > > results(id_student, id_test, date, qualification...) > > I'm using a version of MySQL that doesn't support NOT IN, then I tried in > this way: > > SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE > results.id_test IS NULL AND id_student=".$user > > The query doesn't return anything... What Can I do??? > > Ahead of time, thank you very much, > > Tom. Sorry last mail got lost lol. SELECT * FROM results LEFT JOIN exams USING (id_test) WHERE id_student =".$user; So you get when the user has a result and applied to it. If you dont get a result, he wouldn't have done it yet. (theory) Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php