MySQL Syntax Error for a complex query -
here complex query wrote can't figure out what's problem:
select student.progid, student.batch (student join registers on student.studentid = registers.studentid) join (select offers.courseno (offers join instructor on offers.instructorid = instructor.instructorid)) on offers.courseno = registers.courseno instructor.instructorname = 'p m jaat' , ( offers.acadyear '2007%' or offers.acadyear '2008%' or offers.acadyear '2009%' or offers.acadyear '2010%' or offers.acadyear '2011%' );
this results in error, i'm going leave others tell is:
error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'r1 join (select
double check parenthesis. from
clause is
(student join registers on student.studentid=registers.studentid)
which doesn't make sense.
what want is:
from (student) join registers r1 on (student.studentid=registers.studentid)
or can lose parenthesis:
from student join registers r1 on student.studentid=registers.studentid
p.s. had as r1
in wrong spot.
update: need parenthesis when using subqueries.
from student join registers on student.studentid = registers.studentid join( select courseno offers join instructor on offers.instructorid = instructor.instructorid ) r2 on offers.courseno = registers.courseno
Comments
Post a Comment