If table A value IS NULL then table B - Mailing list pgsql-general

From Marco Lazzeri
Subject If table A value IS NULL then table B
Date
Msg-id 1074880900.3725.17.camel@macbeth.intranet.noze.it
Whole thread Raw
Responses Re: If table A value IS NULL then table B  (Martín Marqués<martin@bugs.unl.edu.ar>)
Re: If table A value IS NULL then table B  ("Ezra Epstein" <eepstein@prajnait.com>)
List 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.lazzeri@noze.it - http://www.noze.it


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Recursive optimization of IN subqueries
Next
From: "Lee Harr"
Date:
Subject: Re: sequence in schema -- broken default