Skip site navigation (1) Skip section navigation (2)

Re: [SQL] Left Join

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Nikolaj Lundsgaard <Nikolaj(at)kampsax(dot)dtu(dot)dk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Left Join
Date: 2000-03-05 14:15:35
Message-ID: Pine.LNX.4.21.0003051451020.347-100000@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-sql
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(at)gmx(dot)net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



In response to

  • Left Join at 2000-03-05 10:43:45 from Nikolaj Lundsgaard

pgsql-sql by date

Next:From: Oleg BartunovDate: 2000-03-05 20:00:39
Subject: statistics using SQL
Previous:From: Nikolaj LundsgaardDate: 2000-03-05 10:43:45
Subject: Left Join

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group