Re: Hotel Booking dates subquery

From: Scotty <invallid_at_invalid.spam>
Date: Sun, 10 Nov 2002 10:18:08 +0000
Message-ID: <rccssusmft2kr0f0b6tusv3k8cs5mitiq4_at_4ax.com>


Sean Case wrote:

>In article <99irsusn3hl706ov9saqp4n63uaublvvsg_at_4ax.com>,
> Scotty <invallid_at_invalid.spam> wrote:
>
>> Scotty wrote:
>
>> select * from booking
>> where booking_id not in (
>> select booking_id
>> from booking
>> where to_date('02-06-01','dd-mm-yy') -- starting date
>> between to_date( startdate,'dd-mm-yy')
>> and to_date( enddate,'dd-mm-yy')
>> or to_date('12-06-01','dd-mm-yy') -- ending date
>> between to_date(startdate,'dd-mm-yy')
>> and to_date(enddate,'dd-mm-yy'));
>
>Suppose there is a booking with startdate = 3-06-01 and
>enddate = 11-06-01. Does this query still work?
>
>Free hint: forget about "between" - it's not actually useful.
>There's a correct query with just two linear comparisons.

Hiya Sean. To be honest I don't know what a linear comparison is and can't find a definition on google.

I'm guessing that it might look like

A              !...................................!
B    !....................................................!

>Another hint: when do two periods of time _not_ overlap?

When the start date is past the end date? I'm even more confused now :-) Received on Sun Nov 10 2002 - 11:18:08 CET

Original text of this message