jmaccs64 Posted June 22, 2009 Share Posted June 22, 2009 Can someone please tell me what is wrong with this query... SELECT students.student_id, students.first_name, students.last_name, students.grad_year, students.grade_level, acad_adv.acad_adv_id, acad_adv.student_id, acad_adv.assigned_resource, acad_adv.assigned_date, acad_adv.present WHERE students.student_id = acad_adv.student_id AND students.student_id LIKE '%" . $name . "%' OR students.last_name LIKE '%" . $name ."%' AND acad_adv.assigned_date = $date AND acad_adv.assigned_resource = $resource Thanks Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/ Share on other sites More sharing options...
Maq Posted June 22, 2009 Share Posted June 22, 2009 Define "wrong". Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/#findComment-861523 Share on other sites More sharing options...
jmaccs64 Posted June 22, 2009 Author Share Posted June 22, 2009 It is not working, should I be using a left join? it says my syntax is wrong... Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/#findComment-861527 Share on other sites More sharing options...
jmaccs64 Posted June 22, 2009 Author Share Posted June 22, 2009 This is directly from phpmyadmin SQL query: Documentation SELECT students.student_id, students.first_name, students.last_name, students.grad_year, students.grade_level, acad_adv.acad_adv_id, acad_adv.student_id, acad_adv.assigned_resource, acad_adv.assigned_date, acad_adv.present WHERE students.student_id LIKE '% smith %' OR students.last_name LIKE '% smith %' AND acad_adv.assigned_date = '05-08-2010' AND acad_adv.assigned_resource =1 AND students.student_id = acad_adv.student_id MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE students.student_id LIKE '% smith %' OR students.last_name LIKE '% s' at line 3 Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/#findComment-861531 Share on other sites More sharing options...
jmaccs64 Posted June 22, 2009 Author Share Posted June 22, 2009 I got it..... Thanks SELECT students.student_id, students.first_name, students.last_name, students.grad_year, acad_adv.assigned_resource, acad_adv.assigned_date FROM students INNER JOIN acad_adv ON students.student_id=acad_adv.student_id WHERE students.last_name LIKE '%smith%' AND acad_adv.assigned_resource = "1" AND acad_adv.assigned_date = "2010-05-08" Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/#findComment-861555 Share on other sites More sharing options...
Maq Posted June 23, 2009 Share Posted June 23, 2009 It is not working, should I be using a left join? it says my syntax is wrong... Thanks in advance! That's still not helpful. What I meant was, do you get an error? What happened and what was supposed to happen? Glad you solved it. Link to comment https://forums.phpfreaks.com/topic/163297-solved-noob-needs-help-with-query/#findComment-861895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.