Conditional expression in an UPDATE statement

From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Conditional expression in an UPDATE statement
Date: 2013-02-07 01:08:05
Message-ID: CAAY=A7_J_=RH5Uy2DhkAB6TuSPxwqG97CKYWr6FPmrgAWxu-3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jasen Betts 2013-02-07 06:41:30 Re: Conditional expression in an UPDATE statement
Previous Message Dev Kumkar 2013-02-06 20:18:01 Re: Facing authentication error on postgres 9.2 -> dblink functions