outer joins

Поиск
Список
Период
Сортировка
Искать

outer joins

От:
"Ken J. Wright" <ken@ori-ind.com>
Дата:
So, is there an eloquent (or not) way to fake an outer join in PostgreSQL?

Ken

Re: [INTERFACES] outer joins

От:
Denis Sbragion <sbragion.denis@usa.net>
Дата:
Hello,

At 19.00 07/03/99 -0800, you wrote:
>So, is there an eloquent (or not) way to fake an outer join in PostgreSQL?

yes! Example of a workaround using unions:

select
	X.a, X.b,
	Y.a, Y.b
from
	X left outer join Y on X.a = Y.a

becomes

select 
	X.a, X.b,
	Y.a, Y.b
from
	X,Y
where
	X.a = Y.a
union
select 
	X.a, X.b,
	null, null
from
	X
where
	not exists (select * from Y where Y.a = X.a)

Little cumbersome but it works.

Bye!

	Sbragion Denis
	InfoTecna
	Tel, Fax: +39 039 2324054
	URL: http://space.tin.it/internet/dsbragio
FAQ