Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 327879F9A28 for ; Thu, 27 Sep 2007 06:27:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 86378-10 for ; Thu, 27 Sep 2007 06:27:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by postgresql.org (Postfix) with ESMTP id 350229F99E5 for ; Thu, 27 Sep 2007 06:27:13 -0300 (ADT) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay01.plus.net with esmtp (Exim) id 1IapeI-00051x-7y; Thu, 27 Sep 2007 10:27:10 +0100 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id CE619274060; Thu, 27 Sep 2007 10:27:09 +0100 (BST) Message-ID: <46FB776D.5080406@archonet.com> Date: Thu, 27 Sep 2007 10:27:09 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Venelin Arnaudov CC: pgsql-sql@postgresql.org Subject: Re: Problems with bulk update References: <46FB6822.9060507@prosyst.com> In-Reply-To: <46FB6822.9060507@prosyst.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/155 X-Sequence-Number: 29368 Venelin Arnaudov wrote: > Hi > > I want to update the values of one column of a table based on the > matches in a second table > something like > update table1 > set table1.field2_new=table2.new_id > from table2 > where table1.field2_old=table2.old_id; Did you try it? http://www.postgresql.org/docs/8.2/static/sql-update.html PG has a non-standard "FROM" extension for just this purpose. -- Richard Huxton Archonet Ltd