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
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 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.