Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3B737634CE4 for ; Fri, 19 Feb 2010 06:38:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84991-01-7 for ; Fri, 19 Feb 2010 10:38:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay.ptn-ipout02.plus.net (relay.ptn-ipout02.plus.net [212.159.7.36]) by mail.postgresql.org (Postfix) with ESMTP id A8CF46347CC for ; Fri, 19 Feb 2010 06:38:07 -0400 (AST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAOf3fUvUnw4U/2dsb2JhbACbB3S8PYRnBI4l Received: from pih-relay08.plus.net ([212.159.14.20]) by relay.ptn-ipout02.plus.net with ESMTP; 19 Feb 2010 10:36:22 +0000 Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1NiQDe-0003H0-3A; Fri, 19 Feb 2010 10:36:22 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTPA id 6C9972740D6; Fri, 19 Feb 2010 10:36:21 +0000 (GMT) Message-ID: <4B7E69A5.4060705@archonet.com> Date: Fri, 19 Feb 2010 10:36:21 +0000 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9pre) Gecko/20100213 Lightning/1.0b1 Shredder/3.0.2pre MIME-Version: 1.0 To: Gordon Ross CC: "pgsql-sql@postgresql.org" Subject: Re: Unable to get UPDATE ... FROM syntax correct References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 35744f556814f8d231ca896ddbc96eb8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/78 X-Sequence-Number: 33677 On 19/02/10 09:25, Gordon Ross wrote: > > UPDATE audit SET key = extension.number FROM extension WHERE audit.record_id > = extension.number; > > But that returns saying "UPDATE 0" Works here - are you sure you don't have any triggers interfering? BEGIN; CREATE TEMP TABLE audit ( id int, record_id int, key varchar, PRIMARY KEY (id) ); CREATE TEMP TABLE extension ( id int, number int, PRIMARY KEY (id) ); INSERT INTO audit VALUES (1,1,''), (2,2,''), (3,3,''); INSERT INTO extension VALUES (-1,1), (-2,2), (-3,3); UPDATE audit SET key = extension.number FROM extension WHERE audit.record_id = extension.number; SELECT * FROM audit ORDER BY id; ROLLBACK; CREATE TABLE INSERT 0 3 INSERT 0 3 UPDATE 3 id | record_id | key ----+-----------+----- 1 | 1 | 1 2 | 2 | 2 3 | 3 | 3 -- Richard Huxton Archonet Ltd