Re: complicated query (newbie..)
От | Sam Mason |
---|---|
Тема | Re: complicated query (newbie..) |
Дата | |
Msg-id | 20090409204245.GV12225@frubble.xen.chris-lamb.co.uk обсуждение исходный текст |
Ответ на | Re: complicated query (newbie..) (Marcin Krol <mrkafk@gmail.com>) |
Список | 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/
В списке pgsql-general по дате отправления: