If table A value IS NULL then table B

From: Marco Lazzeri <marcomail(at)noze(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: If table A value IS NULL then table B
Date: 2004-01-23 18:01:41
Message-ID: 1074880900.3725.17.camel@macbeth.intranet.noze.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Thank you very much, have a wonderful day!

Marco
--
Marco Lazzeri [ n o z e S.r.l. ]
Via Giuntini, 25/29 - 56023 Navacchio - Cascina (PI)
Tel +39 (0)50 754380 - Fax +39 (0)50 754381
mailto:marco(dot)lazzeri(at)noze(dot)it - http://www.noze.it

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erwin Brandstetter 2004-01-23 18:06:44 Re: UNICODE-encoded database does not accept umlaut-characters (solved)
Previous Message Tom Lane 2004-01-23 17:52:29 Re: Recursive optimization of IN subqueries