I have a database that we use in school for equipment ordering in science. Now I want to produce a time table for the department from the tables that contain the teacher, room, class and period information. The tables are:

lessons
lesson_id,days_id,room_id,teacher_id,class_id


days
days_id, day, period

rooms
room_id,room

teachers
teacher_id,name,group,active...

classes
class_id,year,group

When I write this query it needs to produce the NULL fields where teachers have free periods so that I can write the script to display the timetable without having go round the houses in a php script.

TIA for any help

Phil