Re: If table A value IS NULL then table B

Поиск
Список
Период
Сортировка
От vhikida@inreach.com
Тема Re: If table A value IS NULL then table B
Дата
Msg-id 15228.146.74.1.99.1074890739.squirrel@webmail.inreach.com
обсуждение исходный текст
Ответ на Re: If table A value IS NULL then table B  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Ответы Re: If table A value IS NULL then table B  (Marco Lazzeri <marcomail@noze.it>)
Список pgsql-general
As for the outer join, I think that the problem was ambiguous.

Is id_other_table a foreign key to id? Is there at most one row in each
table?


> On Fri, Jan 23, 2004 at 05:15:56PM -0300, Martín Marqués wrote:
>> Mensaje citado por Marco Lazzeri <marcomail@noze.it>:
>>
>> > I want to write a query on table 'main' that if 'id_other_table' is
>> null
>> > returns value from itself, from table 'other' otherwise.
>>
>> SELECT CASE WHEN id_other_table IS NULL THEN id_other_table
>>        ELSE id
>>        FROM main,other
>
> What about COALESCE?
>
> SELECT COALESCE(id_other_table, id) FROM main, other WHERE ...
>
> (Also probably an OUTER JOIN is needed -- see
> http://www.varlena.com/GeneralBits/56.php)
>
> --
> Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
> "Saca el libro que tu religión considere como el indicado para encontrar
> la
> oración que traiga paz a tu alma. Luego rebootea el computador
> y ve si funciona" (Carlos Duclós)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


В списке pgsql-general по дате отправления:

Предыдущее
От: Martín Marqués
Дата:
Сообщение: Re: sequence in schema -- broken default
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: sequence in schema -- broken default