Re: [GENERAL] Simulating an outer join

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Julian Scarfe <jscarfe(at)callnetuk(dot)com>
Cc: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] Simulating an outer join
Date: 2000-01-12 23:45:52
Message-ID: 200001122345.SAA20709@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > UNION ALL
> > SELECT table1.key, NULL
> > FROM table1 WHERE NOT EXISTS
> > (SELECT table2.key FROM table2 WHERE table1.key = table2.key);
>
> FWIW, that's exactly Joe Celko's SQL-89 workaround for OUTER JOINs in 'SQL for
> Smarties'. Well in fact he uses (SELECT * FROM table2 WHERE table1.key =
> table2.key) as the subquery, but I presume that's an insignificant difference.

I am just writing the EXISTS section from my book. I don't think it
matters what fields are returned from an EXISTS subquery. If I am
wrong, someone please let me know.

--
Bruce Momjian | http://www.op.net/~candle
maillist(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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message omid omoomi 2000-01-13 00:51:49 Re: [GENERAL] PSQL Function() help....
Previous Message Sarah Officer 2000-01-12 23:35:06 triggers & functions