Re: complicated query (newbie..)
| От | Marcin Krol | 
|---|---|
| Тема | Re: complicated query (newbie..) | 
| Дата | |
| Msg-id | 49DE2F96.7000308@gmail.com обсуждение исходный текст | 
| Ответ на | Re: complicated query (newbie..) (Sam Mason <sam@samason.me.uk>) | 
| Ответы | Re: complicated query (newbie..) | 
| Список | pgsql-general | 
Sam Mason wrote:
> This is a big hint that things are going wrong.  You need those quotes
> in there, an "integer" is a plain number and not a date.
>
This one does work in the sense of selecting out the wrong host but it
still produces nothing but NULLs!
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))
       ON h.id = m.host_id
   WHERE h.id NOT IN (
     SELECT m.host_id
     FROM reservation r, reservation_hosts m
     WHERE r.id = m.reservation_id
       AND m.host_id IS NOT NULL
       AND (r.start_date,r.end_date) OVERLAPS
('2009-04-09'::date,'2009-04-10'::date)
   ORDER BY h.id, r.start_date)
Regards,
mk
		
	В списке pgsql-general по дате отправления: