Re: Re: FAQ update for 7.1

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-docs(at)postgresql(dot)org
Subject: Re: Re: FAQ update for 7.1
Date: 2001-01-22 06:33:52
Message-ID: 200101220633.BAA22888@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

> On Sat, Nov 04, 2000 at 03:13:26PM -0500, Bruce Momjian wrote:
> > Thanks. I will update it as soon as 7.1 goes beta.
> > >
> > > 4.24) How do I do an outer join?
> > >
> > > Outer joins are supported in 7.1.
> > >
>
> Perhaps throw in an example of the supported syntax? From what I've seen
> discussed here, people coming from other systems will find their outer
> join queries failing, and may end up at this question.

Good idea. Here is an updated FAQ item on outer joins. It will appear
on the web site as soon as I can connect.

---------------------------------------------------------------------------
4.24) How do I do an outer join?

PostgreSQL 7.1 and later supports outer joins. Here are two examples:

SELECT *
FROM t1 LEFT OUTER JOIN t2 ON (t1.col = t2.col);

or

SELECT *
FROM t1 LEFT OUTER JOIN t2 USING (col);

These identical queries join t1.col to t2.col, and return any unjoined
rows in t1. A RIGHT join would return unjoined
rows of table t2. A FULL join would return unjoined rows from t1 and t2.
The word OUTER is optional and is
assumed in LEFT, RIGHT, and FULL joins. Ordinary joins are called INNER
joins.

In previous releases, outer joins can be simulated using UNION and NOT
IN. For example, when joining tab1 and
tab2, the following query does an outer join of the two tables:

SELECT tab1.col1, tab2.col2
FROM tab1, tab2
WHERE tab1.col1 = tab2.col1
UNION ALL
SELECT tab1.col1, NULL
FROM tab1
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
ORDER BY tab1.col1

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Edwin Martin 2001-01-22 16:13:44 7.1 released on 2000-09-01?
Previous Message Robert B. Easter 2001-01-22 06:26:57 Re: docs: syntax.sgml patch