Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL Check if a date exists between certain 2 dates

I have this structure

Hotel (hotelNo, hotelName, city)
Room (roomNo, hotelNo, type, price)  
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)  
Guest(guestNo, guestName, guestAddress)

Ho can I list hotels and rooms that were not reserved on "1-Mar-2022" ?

What i’ve done so far:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SELECT * FROM Hotel h, Room r, Booking b
WHERE h.hotelNo = r.hotelNo AND b.roomNo = r.roomNo
??? AND NOT (b.dateFrom and b.dateTo not contains ‘2022-03-01’) ???

>Solution :

You can use '2022-03-01' NOT BETWEEN b.dateFrom and b.dateTo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading