Re: Hotel Booking dates subquery

From: Sean Case <gsc_at_zip.com.au>
Date: Sun, 10 Nov 2002 15:54:49 +1100
Message-ID: <gsc-77EDF0.15544810112002_at_nasal.pacific.net.au>


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.

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

Sean Case

-- 
Sean Case                       gsc_at_zip.com.au

Code is an illusion.  Only assertions are real.
Received on Sun Nov 10 2002 - 05:54:49 CET

Original text of this message