how to deteck empty tables in outer joins

Поиск
Список
Период
Сортировка
Искать
От
Einar Karttunen
Тема
how to deteck empty tables in outer joins
Дата
Msg-id
Pine.LNX.4.30.0102011347430.24468-100000@melkinpaasi.cs.Helsinki.FI
Ответ на
Список
Дерево обсуждения
list of data types "Derek" <derek.mailer@virgin.net>
Re: list of data types Einar Karttunen <ekarttun@cs.Helsinki.FI>
how to deteck empty tables in outer joins Einar Karttunen <ekarttun@cs.Helsinki.FI>
Re: how to deteck empty tables in outer joins "Robert B. Easter" <reaster@comptechnews.com>
Re: how to deteck empty tables in outer joins Francisco Reyes <fran@reyes.somos.net>
Im trying to do an outerjoin of two tables. The second one might be
empty. Normally I would use a query like:

CREATE TABLE a ( id INTEGER );
CREATE TABLE b ( id INTEGER );

SELECT * FROM a,b
WHERE a.id=b.id
UNION ALL
SELECT * FROM a,b
WHERE a.id NOT IN (b.id)
;

If the seconf table is empty the result is null, because the cartesian
product of table and null is null. What I want is to include a condition
that if b has no rows then just add null for the value of b ie.
SELECT *,NULL FROM a; How can I implement this?

- Einar Karttunen



В списке pgsql-novice по дате отправления
От: Einar Karttunen
Дата:
Сообщение: Re: list of data types
От: Thomas Weholt
Дата:
FAQ