X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id F12689DCBDF for ; Wed, 8 Feb 2006 19:20:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79286-04 for ; Wed, 8 Feb 2006 19:20:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from presinet.com (mail.presinet.com [209.53.156.1]) by postgresql.org (Postfix) with ESMTP id BC1139DC86C for ; Wed, 8 Feb 2006 19:20:29 -0400 (AST) Received: from [10.10.1.151] ([10.10.1.151]) by presinet.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 8 Feb 2006 15:16:30 -0800 Message-ID: <43EA7CCD.3050905@presinet.com> Date: Wed, 08 Feb 2006 15:20:45 -0800 From: Bricklen Anderson User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql@yukonho.de CC: pgsql-sql@postgresql.org Subject: Re: Syntax for "IF" clause in SELECT References: <200602090012.52747.pgsql@yukonho.de> In-Reply-To: <200602090012.52747.pgsql@yukonho.de> Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 08 Feb 2006 23:16:30.0109 (UTC) FILETIME=[B167BCD0:01C62D05] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.135 required=5 tests=[AWL=0.135] X-Spam-Score: 0.135 X-Spam-Level: X-Archive-Number: 200602/89 X-Sequence-Number: 24099 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