Re: CASE SELECT syntax - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: CASE SELECT syntax
Date
Msg-id 20040115182105.GA16635@wolff.to
Whole thread Raw
In response to CASE SELECT syntax  (Marco Lazzeri <marcomail@noze.it>)
Responses Re: CASE SELECT syntax  (Frank Miles <fpm@u.washington.edu>)
List pgsql-general
On Thu, Jan 15, 2004 at 18:23:47 +0100,
  Marco Lazzeri <marcomail@noze.it> wrote:
> What about a SELECT syntax like that?
>
> SELECT
>     CASE WHEN bar.foo_id IS NULL THEN bar.*
>     ELSE foo.*
> FROM foo, bar
>
> Anyway, I need a SELECT query that gets data from a FIRST TABLE if a
> specific value in a SECOND TABLE is NULL or from SECOND TABLE itself if
> the value IS NOT NULL.
>
> Any suggestion?

You almost certainly want some join condition between foo and bar.
You can't actually use *. You will need a CASE for each column.
CASE statements need and END.

pgsql-general by date:

Previous
From: "Rick Gigger"
Date:
Subject: Re: serverless postgresql
Next
From: Martin Marques
Date:
Subject: Re: Foreign key question