Left joins

From: Peter Eisentraut <peter(at)pathwaynet(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Left joins
Date: 1999-07-12 18:25:29
Message-ID: Pine.LNX.4.10.9907121420210.4521-100000@saxony.pathwaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Does anyone know an elegant way of doing a left join like

Table 1
abc 1
def 2
ghi <NULL>

Table 2
1 foo
2 bar
3 duh

I'd like to join those to give me:
abc 1 foo
def 2 bar
ghi <NULL> <NULL>

I can currently only envision a way to do this via a union of several
queries filtering out null and non-null fields, but that gets very
cumbersome when you have lots of fields involved and more than two or
three tables to join.

Any suggestions?

Thanks.

--
Peter Eisentraut
PathWay Computing, Inc.

Browse pgsql-sql by date

  From Date Subject
Next Message Heinz Hemken 1999-07-13 02:18:36 variables in pgSQL?
Previous Message Thomas Good 1999-07-12 16:57:45 Re: [SQL] calculating percentages