Re: OUTER JOIN problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Zoltan Boszormenyi <zboszor(at)freemail(dot)hu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: OUTER JOIN problem
Date: 2004-06-29 21:25:18
Message-ID: 20040629142001.T68031@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 think
select * 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2004-06-29 23:52:24 Re: Question about a CIDR based query
Previous Message Stephan Szabo 2004-06-29 17:46:03 Re: FW: "=" operator vs. "IS"