I have 2 tables dbo.seat and dbo.booking
dbo.seat
noSeat
------
1-2
1-3
1-4
1-8
4-2
4-3
4-4
5-1
5-2
dbo.booking
noBooking | noSeat | statusBooked | endTime
1002 1-4 0 2015-02-16 13:30:00.000
1003 1-4 1 2015-02-17 13:30:00.000
1004 1-8 1 2015-02-17 13:30:00.000
1005 1-2 0 2015-02-16 14:59:00.000
1006 1-3 0 2015-02-16 14:59:00.000
How to take seat.noSeat which is not booked ?
This sample show us that seat number 1-4 and 1-8 is booked. and I want to know what seat is available(the output is all seat.noSeat except 1-4 and 1-8) ?
Table booking is for booking transaction and seat is list of seat provided.
UPDATE :
statusBooked will automatically update to 0 when endTime is equal CurrentTime. it mean it's over and tell us that 1-4 is available until someone booked it again (insert method to dbo.booking statusBooked by default 1)
SELECT s.noSeat FROM seat s INNER JOIN booking b ON s.noSeat = b.noSeat WHERE b.statusBooked <> 1and the result is what is in booking table.