Thread: Conditional expression in an UPDATE statement

Conditional expression in an UPDATE statement

From
JORGE MALDONADO
Date:
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

With respect,
Jorge Maldonado

Re: Conditional expression in an UPDATE statement

From
Jasen Betts
Date:
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