Are you stating then that if an entry exists in the Session_booking table for a given seat number the seat number is booked, otherwise it is available?
Are you intending to provide a seat number as a parameter and have the procedure return whether the seat is available?
Assuming that the presence of an entry indicates the seat is booked, how about something like this which returns a 1 if a given seat is available or 0 if it is not:
Create Procedure IsSeatAvailable
set nocount on
if exists (SELECT Seat_Number FROM Session_Booking
AND Seat_Number = @Seat) RETURN 0
If instead you are looking for a query to give you ALL seats and whether they are available or not, that is a different story. The easiest way to do that is to create a table which contains all the seat numbers then use an outer join as, perhaps:
CASE WHEN SB.Seat_Number IS NULL THEN 'available'
ELSE 'allocated' END as SeatAvail
FROM AllSeats LEFT JOIN Session_booking SB ON AllSeats.SeatNumber=SB.SeatNumber
Note that it might be better to include ALL seats in the booking table with an explicit indicator which states whether the seat is available. Then everything is easy.
Custom Apps, Inc.