Re: JOINS...

From: Dani Oderbolz <oderbolz(at)ecologic(dot)de>
To: psql novice <psql_novice(at)operamail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: JOINS...
Date: 2003-05-13 07:01:41
Message-ID: 3EC09855.1090809@ecologic.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

>
>
>Hi Dani,
>
>I understand that part :)
>
>but what about the extra options you can specify in the join
>condition, like 'outer' , 'inner', 'full' etc
>
>i dont see a circumstance when you would use the extra options...
>
>
Hi,
these options are useful when your tables are partially related.
For example, you have a table products and a table color.
Now some products don't have a color (like a computer Program).
If you would state this join:

Select product.name, color.name
from
product,
color
where product.color_id = color.color_id (This is an INNER Join, by the Way)

You would NOT retreive the products whose
color_id is NULL.

Thats where the OUTER JOIN comes in - but this is - as far as i know-
not directly supported in Postgres.
You have to do this:

Select product.name, color.name
from
product,
color
where product.color_id = color.color_id
UNION
Select product.name, 'No color'
from
product
where
color_id IS NULL;

You find a nice introduction on all this here:

http://spot.colorado.edu/~marangak/main.html

(But they speak about Oracle, not Postgresql)

I hope this gives you some clues.

Cheers, Dani

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2003-05-13 10:25:48 Re: JOINS...
Previous Message Max Bernaert 2003-05-13 06:56:45 Backup or installation problems of het PostgreSql database.