X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C41D9D1B2BD for ; Thu, 24 Jun 2004 15:51:30 -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 42627-04 for ; Thu, 24 Jun 2004 18:51:15 +0000 (GMT) Received: from gatekeeper.fma.co.za (gatekeeper.fma.co.za [196.30.143.210]) by svr1.postgresql.org (Postfix) with ESMTP id 1983ED1B4E5 for ; Thu, 24 Jun 2004 15:51:12 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by gatekeeper.fma.co.za (Postfix) with ESMTP id 20195330F8 for ; Thu, 24 Jun 2004 20:51:12 +0200 (SAST) Received: from gatekeeper.fma.co.za ([127.0.0.1]) by localhost (gatekeeper.fma.co.za [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11113-09 for ; Thu, 24 Jun 2004 20:51:11 +0200 (SAST) Received: from [196.30.143.210] (gatekeeper.fma.co.za [196.30.143.210]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by gatekeeper.fma.co.za (Postfix) with ESMTP id 3F9D33301F for ; Thu, 24 Jun 2004 20:51:09 +0200 (SAST) Message-ID: <40DB229C.9040306@sharp.fm> Date: Thu, 24 Jun 2004 20:51:08 +0200 From: Graham Leggett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040623 X-Accept-Language: en-za, en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Normalising an existing table - how? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at fma.co.za X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/240 X-Sequence-Number: 18185 Hi all, I have an existing table containing a column in it containing a money value. I would like to normalise this column into a separate table, as the money value is to be expanded to contain a tax value, etc. I have been trying to find a SQL query that will do the following: - Select the money column from the table - Populate the new normalised table with each row containing the value from the original money column - Write the primary keys of the new rows in the normalised table, back to a new column in the original table added for this purpose. This third step I am struggling with - can anyone suggest a query that might achieve the writing back of the primary key to the original table? Regards, Graham --