Re: JOINS... - Mailing list pgsql-novice

From Dani Oderbolz
Subject Re: JOINS...
Date
Msg-id 3EC09855.1090809@ecologic.de
Whole thread Raw
In response to JOINS...  ("psql novice" <psql_novice@operamail.com>)
Responses Re: JOINS...
List 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


pgsql-novice by date:

Previous
From: "Max Bernaert"
Date:
Subject: Backup or installation problems of het PostgreSql database.
Next
From: Oliver Elphick
Date:
Subject: Re: JOINS...