Re: If table A value IS NULL then table B

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Marco Lazzeri <marcomail(at)noze(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: If table A value IS NULL then table B
Date: 2004-01-23 20:15:56
Message-ID: 1074888956.401180fcddd40@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mensaje citado por Marco Lazzeri <marcomail(at)noze(dot)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
-------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2004-01-23 20:25:05 Re: sequence in schema -- broken default
Previous Message Lee Harr 2004-01-23 20:14:53 Re: sequence in schema -- broken default