Re: Hotel Booking dates subquery

From: Scotty <invallid_at_invalid.spam>
Date: Sun, 10 Nov 2002 23:34:11 +0000
Message-ID: <5hqtsugqkln657gquou0hi9depojiht07f_at_4ax.com>


Damjan S. Vujnovic wrote:

>Here's the "template" query. For additional explanation see Jan's post.
>It works correct for dates in the past time, and in order to make it
>correct for dates in future time you should change either the query
>or the model you adopted (the way you represent 'eternity' end_date).
>
>SELECT room_id
>FROM rooms
>WHERE room_id NOT IN (
> SELECT DISTINCT room_id
> FROM bookings
> WHERE room_status='occupied' and
> (('29-11-02'>start_date and '29-11-02'<end_date) or
> ('05-12-02'>start_date and '05-12-02'<end_date) or
> ('29-11-02'<start_date and '05-12-02'>end_date))
>)

Damjan thanks!

Not sure what you mean by "the way you represent 'eternity' end_date" but i'll do some reading and see if the bulb lights up.

Cheers

BTW, where do these "Template" queries come from? Do their authors ever get remebered - Fibonacci and Mr Bubble Sort et al. Received on Mon Nov 11 2002 - 00:34:11 CET

Original text of this message