Novice SQL Coder Needs Some Help

  • Thread starter Thread starter AJStein
  • Start date Start date
A

AJStein

Hey all, I am trying to right an SQL Query to get some info from
several tables about various operations in a computer lab, and then
print them out for a web app written in ColdFusion. I have tracked
down the error to the MSQL. I have put the query as it stands into
Access, and I get error 3135: Syntax Error in JOIN operation. Being new
at this (this is my first time using SQL in a serious not just playing
context), I was hoping someone could tell me where I went wrong. Here
is the query as it stands before it is executed:

SELECT lab_tasks.lab_tasks_id, labs.name AS labs_name, staff.netid AS
staff_netid, lab_tasks.remote_addr, lab_tasks.remote_host,
lab_tasks.run_date, lab_tasks.run_time, lab_tasks.user_alert_bool,
lab_tasks.lab_task, lab_tasks.comments, lab_tasks.active FROM labs
RIGHT JOIN (staff RIGHT JOIN tasks ON staff.staff_id =
lab_tasks.staff_id) ON labs.labs_id = lab_tasks.labs_id WHERE
lab_tasks.active = 1 ORDER BY
lab_tasks.run_date,lab_tasks.run_time,labs.name

Obviously, I add the end marker ";" when using this in Access. There is
a prep function that more or less does this in the ColdFusion code.
Even adding the ";", I still cannot get this to work. Any suggestions.

_AJS

PS The names don't seem to confusing to me, but I have been staring at
this stuff all week. If you need further explanation, I can do so.
 
You don't have a Lab_Tasks table in FROM clause and yet you refer to that
table as part of the join statement and in the SELECT clause and in the
WHERE clause and in the ORDER BY clause.

SELECT lab_tasks.lab_tasks_id, labs.name AS labs_name, staff.netid AS
staff_netid, lab_tasks.remote_addr, lab_tasks.remote_host,
lab_tasks.run_date, lab_tasks.run_time, lab_tasks.user_alert_bool,
lab_tasks.lab_task, lab_tasks.comments, lab_tasks.active
FROM labs
RIGHT JOIN (staff RIGHT JOIN tasks
ON staff.staff_id =lab_tasks.staff_id)
ON labs.labs_id = lab_tasks.labs_id
WHERE lab_tasks.active = 1
ORDER BY lab_tasks.run_date, lab_tasks.run_time, labs.name
 
Back
Top