Re: Conditional expression in an UPDATE statement - Mailing list pgsql-sql

From Jasen Betts
Subject Re: Conditional expression in an UPDATE statement
Date
Msg-id keviaq$8bh$3@gonzo.reversiblemaps.ath.cx
Whole thread Raw
In response to Conditional expression in an UPDATE statement  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-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




pgsql-sql by date:

Previous
From: JORGE MALDONADO
Date:
Subject: Conditional expression in an UPDATE statement
Next
From: Bert
Date:
Subject: upsert doesn't seem to work..