Jump to content

[SOLVED] Noob needs help with query!


jmaccs64

Recommended Posts

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

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 

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"

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.