Simulating an outer join

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Simulating an outer join
Date: 2000-01-12 16:11:12
Message-ID: 200001121611.LAA03508@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have been thinking about how to simulate an outer join. It seems the
best way is to do:

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

Comments? I know someone was asking about this recently.

--
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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message davidb 2000-01-12 16:21:54 Re: [GENERAL] identifying performance hits: how to ???
Previous Message Robert Wagner 2000-01-12 15:37:13 identifying performance hits: how to ???