This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi there,
I am building a hotel room availability service and I need to check availability for multiple nights but only where the roomID has entries for each of the nights between arrival and departure.
My current query is:
SELECT
availability.id
,availability.quantity
FROM availability
WHERE availability.checkInDay >= ${firstNightOfStay}
AND availability.checkInDay <= ${lastNightOfStay}
AND availability.roomType = '${data.params.room.type}'
I am storing the days as days since Jan 1st 1970 so when running a search for roomtype RT1 for 4th Dec 4 nights I would run
SELECT
availability.id
,availability.quantity
FROM availability
WHERE availability.checkInDay >= 18600
AND availability.checkInDay <= 18603
AND availability.roomType = 'RT1'
I need it so it only returns data if availability.checkInDay includes 18600,18601,18602,18603 whereas the current query will return a positive result even if the room is not available on any of the days
I hope I've explained myself ok, any help really appreciated
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/mysql/comme...