pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Nikolaj Lundsgaard <Nikolaj@kampsax.dtu.dk>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Left Join
Date: Sun, 5 Mar 2000 15:15:35 +0100 (CET)
Message-ID: <Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain> (raw)
In-Reply-To: <004701bf868f$aeca44c0$bcd426c0@kampsax.dtu.dk>

Nikolaj Lundsgaard writes:

> How do make a left join in postgresql ?

Outer joins aren't supported yet. You can generally do something like

select a2, b2 from a, b where a1 = b1
  union
select a2, NULL from a where a1 not in (select b1 from b);

which is not very extensible to more than two tables. Alternatively you
can make a function that returns the corresponding value from b2 given an
a2 value, or some default if there isn't any corresponding one.

Look into the archives for outer joins for countless specifics on this.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden





view thread (13+ messages)  latest in thread

Message-ID: <Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain>
Permalink:  ../Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain/
Also on:    postgresql.org/message-id/Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: peter_e@gmx.net, Nikolaj@kampsax.dtu.dk
  Subject: Re: [SQL] Left Join
  In-Reply-To: <Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain>
  References: <004701bf868f$aeca44c0$bcd426c0@kampsax.dtu.dk> <Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox