SQL Selecting records where one date range doesn't intersect another -
I am trying to write a simple reservation program for a campground.
I have a desk camp site (a record for each site available in the camp graph).
I have a table for visitors who uses the ID of the camping table as the foreign key along with the date of check and the check out date.
What I need to do is gather a potential investigation and check the date from the user and then gather all the camps that are not being used at any point of that time.
I think I am close to the solution, but there is one piece which I am missing.
I am using 2 questions. 1) Collect all the camps which have been spent during that time frame. 2) Collect all camp sites, which are not in Query 1.
This is my first query:
selected visitors. Compacted, visitor. Check indent, visitors From where checkoutdate visitors are ((visitor check check date)> = # checkdendet # and (visitor check indent) or lt; = # CHECKOUTDATE #) or ((visitor checkautdate) & gt; = # checkdendet # and (visitors) Checkautdate) & lt; = CHECKOUTDATE); I think I'm missing something if #checknetnet # and #checkcodi # are between anyone else's check-in and checkout dates, so do not hold it Takes.
I know that I can divide it between two questions, where one is working with #CheckDDD # and the other is working with #CheckGuedet #, but I think That's a cleaner way to do this and I'm not coming with it.
This is my second, which I think is the way it is OK:
Choose DISTINCT Camp Sites. ID, qryCampS_NotAvailable.CampsiteID Camp camps are included in qryCampS_NotAvailable on campsites.ID = qryCampS_NotAvailable.CampsiteID WHERE ((qryCampS_NotAvailable .CampsiteID))); Thanks, Charles
The requested time period, this simple argument Use two ends overlap when the other end starts before and starts at the other end after the first start:
select v.CampsiteID, v.CheckInDate, v List of visitors from CheckOutDate WHERE v.CheckInDate & lt; = Checkout # and v.CheckOutDate & gt; = # CHECKINDATE #;
Comments
Post a Comment