X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EB2FED975B for ; Wed, 21 Sep 2005 09:36:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 74983-10 for ; Wed, 21 Sep 2005 12:36:23 +0000 (GMT) Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) by svr1.postgresql.org (Postfix) with ESMTP id BC8B4D975A for ; Wed, 21 Sep 2005 09:36:22 -0300 (ADT) Received: obelix.askesis.nl 172.31.0.1 from 172.31.1.8 172.31.1.8 via HTTP with MS-WebStorage 6.0.6249 Received: from Panoramix by obelix.askesis.nl; 21 Sep 2005 14:36:26 +0200 Subject: How to add column from old_table to new_table? From: Joost Kraaijeveld To: "Pgsql-sql@postgresql.org" Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 21 Sep 2005 14:36:26 +0200 Message-Id: <1127306186.20038.21.camel@Panoramix> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.322 required=5 tests=[AWL=-0.198, FORGED_RCVD_HELO=0.05, TO_ADDRESS_EQ_REAL=0.47] X-Spam-Level: X-Archive-Number: 200509/178 X-Sequence-Number: 22725 Hi, I have an old_table with two columns: "id" and "old_attribute". I have new table with the columns "id" and "new_attribute". old_table and new_table contain exactly the same id's. Now I want to copy all the old_attribute from old_table to the corresponding new_attribute in the new_table Is that possible in a SQL script (pgadmin or psql console?) and if so, what is the syntax in this example? I have tried something as: insert into new_table(new_attribute) value( select old_attribute from old_table, new_table where old_table.id = new_table_id) where new_table.id = old_table.id TIA -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 e-mail: J.Kraaijeveld@Askesis.nl web: www.askesis.nl