From: Bricklen Anderson <banderson@presinet.com>
To: pgsql@yukonho.de
Cc: pgsql-sql@postgresql.org
Subject: Re: Syntax for "IF" clause in SELECT
Date: Wed, 08 Feb 2006 15:20:45 -0800
Message-ID: <43EA7CCD.3050905@presinet.com> (raw)
In-Reply-To: <200602090012.52747.pgsql@yukonho.de>
References: <200602090012.52747.pgsql@yukonho.de>
pgsql@yukonho.de wrote:
> Greetings,
>
> the following is an MySQL statement that I would like to
> translate to PostgreSQL:
>
> Could someone point me to a documentation of a coresponding
> Systax for an "IF" clause in the a SELECT,
> or is the some other way to do this....
>
> select
> if(spektrum is null,' ','J'),
> if(s19 is null,' ','J'),
> if(OhneGrenze is null,' ','J'),
> from namen;
>
>
> Do I need to create my own function to allow this behaviour!
>
>
> my best regards,
>
> Stefan
use CASE
Since I'm not a user of MySQL, and if I'm reading your query correctly:
try
select (CASE when spektrum is null then 'J' else spektrum end),
...
or if you are just trying to replace nulls, then try COALESCE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: banderson@presinet.com, pgsql@yukonho.de
Subject: Re: Syntax for "IF" clause in SELECT
In-Reply-To: <43EA7CCD.3050905@presinet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox