Re: CASE SELECT syntax

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Marco Lazzeri <marcomail(at)noze(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CASE SELECT syntax
Date: 2004-01-15 18:21:05
Message-ID: 20040115182105.GA16635@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 15, 2004 at 18:23:47 +0100,
Marco Lazzeri <marcomail(at)noze(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Marques 2004-01-15 18:34:32 Re: Foreign key question
Previous Message Rick Gigger 2004-01-15 18:14:14 Re: serverless postgresql