Select available and unavalible slots from three mysql tables

I have three tables which fill out a grid of slots it shows available and unavailable slots against room and time.
The tables and the relations are as below:

relational tables

Classes can be active or inactive. In my query i want to show alll active classes and free slots which are kept in class_info table.
My query here shows all including active and inactive.

SELECT * FROM class_info LEFT JOIN class_slots ON class_slots.class_info_id =
class_info.class_info_id LEFT JOIN class ON class.class_id = class_slots.class_id
WHERE active = 1

I would like to be able to show only active class and those that dont exist as free slots.

Some class will become inactive after a time period however I would like to keep it as history, when this becomes inactive the slots become free and are no longer needed to be shown with the query above all are shown even if it is inactive.

Direct Link






Both comments and pings are currently closed.

Comments are closed.