Jump to content


This topic is now archived and is closed to further replies.


Many levels in a self-join

Recommended Posts

Hi!! I\'m currently building a cinema seat booking system via WAP and I would like some help on the databese administration.

The three tables I use for reservations are the following:

Movies_Projection: Movie_Projection_ID(Primary Key), Movie_ID, Cinema_ID, Movie_Time, Movie_Date

This table is used to produce the Movie_Projection_ID for a certain movie, which is used to filter the table Orders and select the orders for this Movie_Projection_ID. The table Orders is the following:

Orders: Ticket_ID(Primary Key), Movie_Projection_ID, Cinema_Configuration_ID, Price_ID, VAT_ID, Cinema_Seat_State, Customer_ID, Order_Time, Order_Date.

After the filtering I can get all the Cinema_Configuration_IDs which are booked and use them to filter the table Cinema_Configuration which is already filled with all the cinema seats and is the following:

Cinema_Configuration: Cinema_Configuration_ID(Primary Key), Cinema_ID, Cinema_Row_Number, Cinema_Row_Alphabetic, Cinema_Seat_Number, Cinema_Sector. So I can get all the empty seats in a certain cinema.

What I would like to do is to write a SELECT statement that would find all the empty and continuous seats grouped by one, two, three, four, five, etc. according to the number of tickets the user desires. The only way I can think of is many Self-Joins...Is there a better way?

Thank you for your help in advance...and sorry for the long message...

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.