Re: OUTER JOIN problem - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: OUTER JOIN problem
Date
Msg-id 20040629142001.T68031@megazone.bigpanda.com
Whole thread Raw
In response to OUTER JOIN problem  (Zoltan Boszormenyi <zboszor@freemail.hu>)
List pgsql-sql
On Wed, 23 Jun 2004, Zoltan Boszormenyi wrote:

> I don't know how PostgreSQL works internally but this bug *must* be
> conforming to some standard if two distinct SQL server products behave
> (almost) the same. I said almost, I discovered the same annoyance today
> on an Informix 9.21 running under SCO UNIX on a slightly larger dataset
> with less than 70 rows. It just left out some arbitrary rows that had
> NULLs from the right side table (i.e not existing rows).

It's not a bug.  The outerness of the join is defined over the join
conditions (the ON portion), not the where conditions.  In the first case
you got rows from the join that matched the join condition like (a.i=2,
c.a=1, c.b=2) which the where then filtered out.

I thinkselect * from a left outer join c on (a.i=c.a and c.b=1)
meets the standard and may give you what you want.


pgsql-sql by date:

Previous
From: Zoltan Boszormenyi
Date:
Subject: OUTER JOIN problem
Next
From: Josh Berkus
Date:
Subject: Re: Question about a CIDR based query