Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
How can I select from a table where rows exist for all values?
Post Flair (click to view more posts with a particular flair)
Post Body

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

Author
Account Strength
90%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
691
Link Karma
293
Comment Karma
398
Profile updated: 5 days ago
Posts updated: 2 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago