Re: JOINS...

Поиск
Список
Период
Сортировка
От Dani Oderbolz
Тема Re: JOINS...
Дата
Msg-id 3EC09855.1090809@ecologic.de
обсуждение исходный текст
Ответ на JOINS...  ("psql novice" <psql_novice@operamail.com>)
Ответы Re: JOINS...  (Oliver Elphick <olly@lfix.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: "Max Bernaert"
Дата:
Сообщение: Backup or installation problems of het PostgreSql database.
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: JOINS...