Question:
SQL Syntax Error..Need Help Urgent!!?
2012-01-06 19:02:26 UTC
Hi,

I am facing this error: 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 'FROM user_course_confirmation ucc, user_course_selection ucs, course_session cs ' at line 5


Where my code is:
Select
ucc.User_Course_Confirmation_id, ucc.User_Course_Selection_User_Course_Selection_id,
ucs.User_Course_Selection_id, ucs.User_User_id, ucs.Course_Session_Course_Session_id,
cs.Course_Session_id, cs.Course_Course_id,
FROM user_course_confirmation ucc, user_course_selection ucs, course_session cs
WHERE ucs.Course_Session_Course_Session_id = '".$Course_Session_id."'
AND ucs.Course_Session_Course_Session_id = cs.Course_Session_id
AND ucc.User_Course_Selection_User_Course_Selection_id = ucs.User_Course_Selection_id


How to solve this error? Thanks. =)
Four answers:
2012-01-06 19:10:46 UTC
You have an extra comma right before the word FROM You need to remove it.
Ratchetr
2012-01-07 03:14:34 UTC
You have a comma right before your FROM clause, that is what MySQL is complaining about right now.



Drop the comma at the end of this line:

cs.Course_Session_id, cs.Course_Course_id,



That will get rid of the first error.



I'm a bit unsure about this line:

ucs.Course_Session_Course_Session_id = '".$Course_Session_id."'



But it might work.
no1home2day
2012-01-07 03:04:39 UTC
Can't say for certain, but don't you need either an Inner Join or an Outer Join (i.e. some kind of Join on something)?
Dave, the IT guy
2012-01-07 03:04:36 UTC
You are referencing the tables wrong in the "FROM" portion of the statement.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...