I have the following table structure:
`user`
id(PK)
name
`course`
id(PK)
classid(FK) --> class.id
teacherid(FK) --> user.id
starttimeid(FK) --> timetable_time.id
endtimeid(FK) --> timetable_time.id
name
`class`
id(PK)
name
`course_timetableday`
id(PK)
timetable_dayid(FK) --> timetable_day.id
`timetable_day`
id(PK)
value
`timetable_time`
id(PK)
value
I want to show all the courses for a particular teacherid
along with its classname, timetable_day.value and timetable_time.value(starttimeid and endtimetimeid).
I have tried the following query:
SELECT `course`.*, `class`.`name`, `timetable_day`.*, `course_timetable`.*, `timetable_time`.* FROM (`course`) JOIN `class` ON `class`.`id` = `course`.`classid` JOIN `user` ON `user`.`id` = `course`.`teacherid` JOIN `course_timetable` ON `course_timetable`.`courseid` = `course`.`id` JOIN `timetable_day` ON `timetable_day`.`id` = `course_timetable`.`timetable_dayid` JOIN `timetable_time` AS tt1 ON `tt1`.`id` = `course`.`starttimeid` JOIN `timetable_time` AS tt2 ON `tt2`.`id` = `course`.`endtimeid` WHERE `user`.`id` = 0
This gives me the following error(Though, the table is present. I've tried other queries from the same table and they all work):
Unknown table 'timetable_time'