ON condition in LEFT OUTER JOIN doesn't work?!

From: Marcin Krol <mrkafk(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: ON condition in LEFT OUTER JOIN doesn't work?!
Date: 2009-04-09 16:34:27
Message-ID: 49DE2393.9070402@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello everyone,

I've got this query:

SELECT hosts.id, MIN(reservation.start_date)
FROM hosts
LEFT OUTER JOIN reservation_hosts
ON reservation_hosts.host_id = hosts.id
LEFT OUTER JOIN reservation
ON (reservation_hosts.reservation_id = reservation.id AND
reservation.start_date > 2009-04-09)
GROUP BY hosts.id ORDER BY hosts.id

It selects the hosts with reservation.start_date = 2009-04-09 !

Regards,
mk

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-04-09 16:36:45 Re: complicated query (newbie..)
Previous Message linnewbie 2009-04-09 16:27:42 Storing HTML: HTML entities being rendered in that raw form