Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 4169E6332B1 for ; Fri, 19 Feb 2010 06:28:41 -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 82774-06 for ; Fri, 19 Feb 2010 10:28:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-out.abv.bg (smtp-out.abv.bg [194.153.145.99]) by mail.postgresql.org (Postfix) with ESMTP id 27A486330E4 for ; Fri, 19 Feb 2010 06:28:13 -0400 (AST) Received: from smtp.abv.bg (m2.ni.bg [192.168.151.127]) by smtp-out.abv.bg (Postfix) with ESMTP id 16A2814EDDA; Fri, 19 Feb 2010 12:26:00 +0200 (EET) DomainKey-Signature: a=rsa-sha1; s=smtp-out; d=abv.bg; c=simple; q=dns; b=vMIogMHSU8S6Tu+8XGe49fJBlLehoykcitACZImYv1owUBhmHDSiNar1FSZpCqTW4 I2261ihjl7y/NtTcR+WEpm/2/IFM+Hdl5Hoy13mlQDs8mEtWXF/87b40Jrg/z1QpD9F QUVzGIHUPBAqzixkNn76NV3f6kv38wQkdcSDhp8= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=abv.bg; s=smtp-out; t=1266575160; bh=USLpl530p4IcAjC17GfB9jgO7rgEkQITGyrCXJ91Tsc=; h=Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc: Content-Transfer-Encoding:Message-Id:References:To:DKIM; b=EYqWVYH iFKb3FBm1IBY5pYURER1jBwRASSjNAmrtofbZbt+zRly0BemsJ6wmRY1t/JrshvUIGM NJgga9ZEZm+VDVnfazuBdL+79USos3sroaoNDG4rB9WN6Ahl+W3W/Gl+Tgqgc2urIJA DMdKOkGGvFAt7SE6eo0eoCwh5Ya+Gs= Received: from Unknown (HELO [192.168.180.2]) (78.90.12.216) (smtp-auth username iuzkan@abv.bg, mechanism plain) by smtp.abv.bg (qpsmtpd/0.82) with ESMTPA; Fri, 19 Feb 2010 12:28:11 +0200 Subject: Re: Unable to get UPDATE ... FROM syntax correct Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: zkn In-Reply-To: Date: Fri, 19 Feb 2010 12:28:10 +0200 Cc: Gordon Ross Content-Transfer-Encoding: quoted-printable Message-Id: References: To: pgsql-sql@postgresql.org X-Mailer: Apple Mail (2.1077) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/75 X-Sequence-Number: 33674 update audit set key =3D (select extension.number from extension where = audit.record_id =3D extension_id) On 19.02.2010, at 11:25, Gordon Ross wrote: > I have two tables: >=20 > Table "public.audit" > Column | Type | Modifiers > ------------+----------------------+----------- > id | integer | (serial) > record_id | integer | not null > key | character varying | > (...) >=20 >=20 > Table "public.extension" > Column | Type | Modifiers > ---------+------------+------------ > id | integer | (serial) > number | integer | > (...) >=20 >=20 > 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 >=20 > I tried: >=20 > UPDATE audit SET key =3D extension.number FROM extension WHERE = audit.record_id > =3D extension.number; >=20 > But that returns saying "UPDATE 0" >=20 > However, doing: >=20 > SELECT audit.record_id, extension.number FROM audit, extension WHERE > audit.record_id =3D extension.id; >=20 > Works fine. >=20 > Can someone tell me what I'm doing wrong ? >=20 > Thanks, >=20 > GTG >=20 >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >=20