| From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: complicated query (newbie..) |
| Date: | 2009-04-09 20:42:45 |
| Message-ID: | 20090409204245.GV12225@frubble.xen.chris-lamb.co.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Apr 09, 2009 at 08:16:55PM +0200, Marcin Krol wrote:
> Sam Mason wrote:
> >On Thu, Apr 09, 2009 at 07:25:42PM +0200, Marcin Krol wrote:
> >>SELECT h.id, r.id, r.start_date, r.end_date
> >> FROM hosts h
> >> LEFT JOIN (reservation_hosts m INNER JOIN reservation r
> >> ON m.reservation_id = r.id
> >> AND (r.start_date,r.end_date) OVERLAPS
> >> ('2009-04-09'::date,'2009-04-10'::date))
>
> >The dates here are the date range that you want to give to the user; I
> >was assuming that just because somebody doesn't have a reservation at
> >the moment you still don't want to put reservations going backwards and
> >forwards to infinity.
>
> Not backwards, but forward into some reasonable range, like 3 months (I
> want the user to see the nearby reservation in future).
I'm not sure if this is a question or something else. If you're
wondering how to do this just use a range of ('2009-01-01'::date,
'2009-12-31'::date) to show all entries for this year.
--
Sam http://samason.me.uk/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bernard Barton | 2009-04-09 22:56:37 | Evidently no support for the mmddyyyy date format |
| Previous Message | Dave Page | 2009-04-09 19:52:32 | Re: Some suggestions for the non Linux installers |