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

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ON condition in LEFT OUTER JOIN doesn't work?!
Date: 2009-04-09 16:40:10
Message-ID: 20090409164010.GS12225@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 09, 2009 at 06:34:27PM +0200, Marcin Krol wrote:
> 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 !

You are putting quotes in there, and not comparing to the number 1996
((2009 - 4) - 9), aren't you? Old versions of PG would let this sort of
thing through I think, but newer versions will give an error.

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Glyn Astill 2009-04-09 16:45:23 Re: Trigger function cost
Previous Message Sam Mason 2009-04-09 16:36:45 Re: complicated query (newbie..)