mercredi 22 juillet 2015

select data from multiple condition -SQLite

I have 2 tables room and booking. Trying to make a prototype of hotel management these two table has the following schema image

So the idea is to return all the rooms that are available. To get so, there can be two category. either the room has been checked out which means check out date will be less than today's date(or the next check in date) Or the room has not been booked for at least once (no booking done for this room yet.)

the query is thus little tricky. I managed to only do the first part.

select room_no 
from room,booking 
where room.room_no= booking.rooms 
and (booking.check_out < strftime('%s', 'now'))`

check_in and check_out are stored in epoch time second

How can i edit the query so that it returns the unbooked rooms also?

Aucun commentaire:

Enregistrer un commentaire