pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexandru COSTIN <acostin@rds.ro>
To: pgsql-sql@postgresql.org
Subject: Re: Outer join statement ?
Date: Thu, 31 Aug 2000 06:54:46 GMT
Message-ID: <Winr5.19$bo5.752@nreader1.kpnqwest.net> (raw)
References: <fb-3008002344340001@du-211-67.lyon.dialup.freesurf.fr>

    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@techbourse.com> wrote in message
news:fb-3008002344340001@du-211-67.lyon.dialup.freesurf.fr...
> 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 dédié le NASDAQ
> http://www.techbourse.com





view thread (2+ messages)

Message-ID: <Winr5.19$bo5.752@nreader1.kpnqwest.net>
Permalink:  ../Winr5.19$bo5.752@nreader1.kpnqwest.net/
Also on:    postgresql.org/message-id/Winr5.19$bo5.752@nreader1.kpnqwest.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: acostin@rds.ro
  Subject: Re: Outer join statement ?
  In-Reply-To: <Winr5.19$bo5.752@nreader1.kpnqwest.net>
  References: <fb-3008002344340001@du-211-67.lyon.dialup.freesurf.fr> <Winr5.19$bo5.752@nreader1.kpnqwest.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox