From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: Conditional expression in an UPDATE statement
Date: 7 Feb 2013 06:41:30 GMT
Message-ID: <keviaq$8bh$3@gonzo.reversiblemaps.ath.cx> (raw)
References: <CAAY=A7_J_=RH5Uy2DhkAB6TuSPxwqG97CKYWr6FPmrgAWxu-3A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
On 2013-02-07, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
> Can I use a conditional expression in an UPDATE query like this:
>
> UPDATE table_1 SET
> field_1 =
> CASE WHEN (condition) THEN (COALESCE(query_1, -1))
> ELSE (COALESCE(query_1, -2))
> END
>
yesh, that should work.
--
⚂⚃ 100% natural
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
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: jasen@xnet.co.nz
Subject: Re: Conditional expression in an UPDATE statement
In-Reply-To: <keviaq$8bh$3@gonzo.reversiblemaps.ath.cx>
* 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