Re: If table A value IS NULL then table B

Поиск
Список
Период
Сортировка
От Martín Marqués
Тема Re: If table A value IS NULL then table B
Дата
Msg-id 1074888956.401180fcddd40@bugs.unl.edu.ar
обсуждение исходный текст
Ответ на If table A value IS NULL then table B  (Marco Lazzeri <marcomail@noze.it>)
Ответы Re: If table A value IS NULL then table B  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Список pgsql-general
Mensaje citado por Marco Lazzeri <marcomail@noze.it>:

> I've got a table called 'main' described as follow
>
> CREATE TABLE main (
>   id_other_table INT,
>   value CHAR
> );
>
> and a table called 'other' described as follow
>
> CREATE TABLE other (
>   id INT PRIMARY KEY,
>   value CHAR
> );
>
> 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

> Thank you very much, have a wonderful day!

Same for you.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-------------------------------------------------------
Martín Marqués          |   Programador, DBA
Centro de Telemática    |     Administrador
               Universidad Nacional
                    del Litoral
-------------------------------------------------------

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

Предыдущее
От: "Lee Harr"
Дата:
Сообщение: Re: sequence in schema -- broken default
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: sequence in schema -- broken default