Open AvesonThyBot opened 4 months ago
SELECT * FROM hotel_info WHERE roomName = ? AND NOT EXISTS ( SELECT 1 FROM hotel WHERE hotel.roomType = hotel_info.roomID AND ( (startDate <= ? AND endDate >= ?) OR (startDate >= ? AND startDate <= ?) OR (endDate >= ? AND endDate <= ?) ) );
This query checks if the date time is valid and then return all information about rooms roomName startDate endDate startDate (repeated) endDate (repeated) startDate (repeated) endDate (repeated)
Checking for a rooms availability is done through picking date range and then picking room type. if the room type is not free it will not show up. Instead it would be more benifical to show all the rooms that will be available and the quantity of room that will be free during that time. Also only allow them to book one as the data or fetch data actively on every step of redirecting or there will be colliding booking.