Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3LP9-0003ks-Mc for pgsql-sql@arkaria.postgresql.org; Thu, 07 Feb 2013 06:56:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3LP9-0001nI-4Q for pgsql-sql@arkaria.postgresql.org; Thu, 07 Feb 2013 06:56:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3LP7-0001m0-Nt for pgsql-sql@postgresql.org; Thu, 07 Feb 2013 06:56:17 +0000 Received: from plane.gmane.org ([80.91.229.3]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3LP3-0003Vc-5X for pgsql-sql@postgresql.org; Thu, 07 Feb 2013 06:56:17 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1U3LPI-00009A-QU for pgsql-sql@postgresql.org; Thu, 07 Feb 2013 07:56:28 +0100 Received: from ip-118-90-110-209.xdsl.xnet.co.nz ([118.90.110.209]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Feb 2013 07:56:28 +0100 Received: from jasen by ip-118-90-110-209.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Feb 2013 07:56:28 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: Conditional expression in an UPDATE statement Date: 7 Feb 2013 06:41:30 GMT Organization: Dis (not Dat) Organisation Lines: 15 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-110-209.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 2013-02-07, JORGE MALDONADO 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