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 8CF57D7A0A for ; Thu, 22 Sep 2005 07:52:22 -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 22136-09 for ; Thu, 22 Sep 2005 10:52:15 +0000 (GMT) Received: from mail1.chaos1.de (Mail1.Chaos1.de [213.160.12.53]) by svr1.postgresql.org (Postfix) with ESMTP id 71FC1DA2A1 for ; Thu, 22 Sep 2005 07:52:15 -0300 (ADT) Received: from claudius6.in.chaos1.de ([192.168.220.106]) by mail1.chaos1.de with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.44) id 1EIOgb-0005MH-6Q for pgsql-sql@postgresql.org; Thu, 22 Sep 2005 12:52:18 +0200 Mime-Version: 1.0 (Apple Message framework v622) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: pgsql-sql@postgresql.org From: Axel Rau Subject: Updating cidr column with network operator Date: Thu, 22 Sep 2005 12:52:16 +0200 X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.103 required=5 tests=[AWL=-0.103, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200509/200 X-Sequence-Number: 22747 Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY KEY , -- 'PK, ,IPv4/6 Network address' ) CREATE TABLE address ( id inet PRIMARY KEY , -- 'PK of IPv4/6 host address' network cidr NOT NULL -- 'FK to Network table' REFERENCES network ON DELETE CASCADE ON UPDATE CASCADE ) I tried (using the WHERE clause to eliminate the addresses were no corresponding net exists): UPDATE address SET network = (SELECT N.id WHERE A.id << N.id) FROM address A, network N WHERE A.id << N.id; But this ended up with all network columns pointing at the same net (-:). Any help would be appreciated. Axel Axel Rau, Frankfurt, Germany +49-69-951418-0