Re: Outer join statement ?

From: "Alexandru COSTIN" <acostin(at)rds(dot)ro>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Outer join statement ?
Date: 2000-08-31 06:54:46
Message-ID: Winr5.19$bo5.752@nreader1.kpnqwest.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,
There are 2 ways of doing outer joins, both are relatively expensive
from the CPU time point of view
1. Create a function that returns the ojined value, or null if the value
does not exists in the secod table
2. Use a union beetwen a left join and a straight select with a where
condition. Next there's an example inspired from the Adison Westley book (I
suggest you grab a copy from the postgresql site. (/docs)

select customer.name,salesorder.order_id from customer join salesorder
on customer.cust_id=salesorder.fk_cust_id union all select
customer.name,null::int4 from customer where customer.cust_id not in (select
fk_cust_id from salesorder);

Probably an improvement here is to use exists on the second select, but
I didn't have the time to document.
Anyway, this will not work embedded in a view ("union all" is not
supported in views).

Alexander

"Nasdaq" <fb(at)techbourse(dot)com> wrote in message
news:fb-3008002344340001(at)du-211-67(dot)lyon(dot)dialup(dot)freesurf(dot)fr(dot)(dot)(dot)
> The statement "Outer Join" is not available in Postgres ?
> Is there an extension provided by a third company that implement this
> functionnality ?
>
> If not do you know when this functionnality will be available in
> Postgres ?
>
> Thank
>
> Fred
>
> --
> TechBourse : le premier site en FRANCAIS ddi le NASDAQ
> http://www.techbourse.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mads Jensen 2000-08-31 18:22:19 Auto increment
Previous Message Igor N. Avtaev 2000-08-31 03:45:22 Re: 7.0.2 questions on encoding and compilation