CREATE PROCEDURE `getTestById`(IN `studID` INT,IN `tID` INT)
BEGIN
SELECT t.id,t.name,c.name category,i.name instructor,getQuestionsInTest(t.id) questions,ts.startTime,ts.duration,ts.passPercent,ts.endTime,ts.id settingID,ts.random from groups g
inner join groups_has_students gs on gs.studentID = studID and g.id = gs.groupID
inner join test t on t.id = g.assignedTest
inner join test_settings ts on ts.id = g.settingID
inner join category c on c.id = t.categoryID
inner join instructor i on i.id = t.instructorID
where (convert_tz(now(),@@session.time_zone,'+02:00') BETWEEN ts.startTime AND ts.endTime) AND t.id NOT IN (SELECT testID from result where studentID = gs.studentID) AND t.id = tID;
END;
Gives following error
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 'groups g inner join groups_has_students gs on gs.studentID = studID ' at line 3
I tried enclosing groups in back quotes but didnt work
Any solution what's wrong?