Re: SQL-question (JOIN)

Поиск
Список
Период
Сортировка
Искать
От
Peter Eisentraut
Тема
Re: SQL-question (JOIN)
Дата
Msg-id
Pine.LNX.4.44.0302010200100.789-100000@localhost.localdomain
Ответ на
SQL-question (JOIN) (pilsl@goldfisch.at)
Список
Дерево обсуждения
SQL-question (JOIN) pilsl@goldfisch.at
Re: SQL-question (JOIN) Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: SQL-question (JOIN) Bruno Wolff III <bruno@wolff.to>
Re: SQL-question (JOIN) Keary Suska <hierophant@pcisys.net>
Re: SQL-question (JOIN) Peter Eisentraut <peter_e@gmx.net>
pilsl@goldfisch.at writes:

> table1:
> uid | name
> ----+-----
> 1   | bob
> 2   | jim
> 3   | tom
>
> table2:
> uid | name
> ----+-----
> 2   | frank
>
>
> the final join should return:
> uid | name
> ----+-----
> 1   | bob
> 2   | frank
> 3   | tom

select uid, coalesce(table2.name, table1.name) as name from table1 left
join table2 using (uid);

-- 
Peter Eisentraut   peter_e@gmx.net

В списке pgsql-general по дате отправления
От: Bruno Wolff III
Дата:
Сообщение: Re: SQL-question (JOIN)
От: Curt Sampson
Дата:
Сообщение: Re: Status of tablespaces
FAQ