Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5CB4F632D53 for ; Fri, 19 Feb 2010 05:50:40 -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 75265-01 for ; Fri, 19 Feb 2010 09:50:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-1.csi.cam.ac.uk (ppsw-1.csi.cam.ac.uk [131.111.8.131]) by mail.postgresql.org (Postfix) with ESMTP id 8F97A6322FF for ; Fri, 19 Feb 2010 05:50:29 -0400 (AST) X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from pantagruel.csi.private.cam.ac.uk ([172.28.10.198]:6039 helo=panurge.staff-ad.csi.cam.ac.uk) by ppsw-1.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.131]:25) with esmtp id 1NiP7O-000728-3u (Exim 4.70) for pgsql-sql@postgresql.org (return-path ); Fri, 19 Feb 2010 09:25:50 +0000 Received: from Panurge.staff-ad.csi.cam.ac.uk (131.111.10.208) by pantagruel.staff-ad.csi.private.cam.ac.uk (172.28.10.198) with Microsoft SMTP Server (TLS) id 8.1.393.1; Fri, 19 Feb 2010 09:26:41 +0000 Received: from gargantua.staff-ad.csi.cam.ac.uk ([172.28.10.197]) by Panurge.staff-ad.csi.cam.ac.uk ([131.111.10.208]) with mapi; Fri, 19 Feb 2010 09:27:31 +0000 From: Gordon Ross To: "pgsql-sql@postgresql.org" Date: Fri, 19 Feb 2010 09:25:48 +0000 Subject: Unable to get UPDATE ... FROM syntax correct Thread-Topic: Unable to get UPDATE ... FROM syntax correct Thread-Index: AcqxRYVBi+vxbjmqykmMcNsESgkkTA== Message-ID: Accept-Language: en-US Content-Language: en X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.185 tagged_above=-10 required=5 tests=BAYES_40=-0.185 X-Spam-Level: X-Archive-Number: 201002/74 X-Sequence-Number: 33673 I have two tables: Table "public.audit" Column | Type | Modifiers ------------+----------------------+----------- id | integer | (serial) record_id | integer | not null key | character varying | (...) Table "public.extension" Column | Type | Modifiers ---------+------------+------------ id | integer | (serial) number | integer | (...) The column "key" was recently added to the "audit" table, and I wish to populate it with the value form the "number" column in the extension table. The join between the tables is audit.record_id =3D extension.id I tried: UPDATE audit SET key =3D extension.number FROM extension WHERE audit.record= _id =3D extension.number; But that returns saying "UPDATE 0" However, doing: SELECT audit.record_id, extension.number FROM audit, extension WHERE audit.record_id =3D extension.id; Works fine. Can someone tell me what I'm doing wrong ? Thanks, GTG