[PHP] 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. -- 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] 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
RE: [PHP] Re: Help with query
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:[EMAIL PROTECTED] Sent: Tuesday, February 21, 2006 7:57 AM To: php-general@lists.php.net Subject: [PHP] 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
[PHP] RE: Help with Query
Hi there. I have the following question for u. I want to join two tables but it must be displayed in the a specific format. The data of the tables are as follow : Table employee : idsurname initialsba 1 PoepH ER 2 SnotC ER 3 Skoen AS ER 4 Sak Q WQ Table courses_completed : idcourse_id completed 1 WH1.1 Yes 1 WH1.2 Yes 1 WH1.3 Yes 2 WH1.1 Yes 2 WH1.2 Yes 3 WH1.1 Yes 3 WH1.2 Yes 3 WH1.4 Yes 3 WH1.5 no 4 PS1.1 Yes 4 PS1.2 Yes 4 PS1.5 Yes 1 PS1.2 Yes 1 PS1.2 Yes I want to have the following data in a temp table or query : idsurname initialsba WH1.1 WH1.2 WH1.3 WH1.4 1 PoepH ER Yes Yes Yes Yes 2 SnotC ER Yes Yes Yes Yes 3 Skoen AS ER Yes Yes Yes Yes idsurname initialsba PS1.1 PS1.2 PS1.4 PS1.5 1 PoepH ER Yes Yes Yes Yes 4 Sak Q WQ Yes Yes Yes Yes I want to make all the copies of person listed in the rows listed just in one row,with all his skills listed in colums in that some row. The information above must be displayed in Exel just like this.There is about 50 of these courses in one production line,and there is 8 production lines. Is there a way that i can do this or how must i join this tables to get a table in that form? thank u hoender -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]