X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 659B19DCB13 for ; Tue, 28 Mar 2006 13:14:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11569-05 for ; Tue, 28 Mar 2006 13:14:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 22DC79DC9DD for ; Tue, 28 Mar 2006 12:51:48 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (T8b28.t.pppool.de [89.55.139.40]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id E9125656CF; Tue, 28 Mar 2006 18:52:25 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C8AE2185433DC; Tue, 28 Mar 2006 18:51:55 +0200 (CEST) Message-ID: <442969AB.2020604@logix-tt.com> Date: Tue, 28 Mar 2006 18:51:55 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Fay Du Cc: pgsql-sql@postgresql.org Subject: Re: Update question References: <00b801c65286$7ca8f260$b8d849c6@versaterm.com> In-Reply-To: <00b801c65286$7ca8f260$b8d849c6@versaterm.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] X-Spam-Score: 0.112 X-Spam-Level: X-Archive-Number: 200603/446 X-Sequence-Number: 24792 Hi, Fay, Fay Du wrote: > Table cost > > Id edge_id cost > 1 30 101.4 > 2 30 null > 3 40 500.2 > 4 40 null > 5 45 300.7 > 6 45 null > I want to set cost value with same edge_id by same value. The existing > values are calculated by calling a function (calculate edge length). I > can calculate the value by same function, but the function was slow. I > wander if I can use update statement to set the second value with same > edge_id. Thanks in advance for your help. It should go like: UPDATE cost SET edge_id = (SELECT cost FROM cost innr WHERE innr.edge_id = edge_id AND innr.cost is not null) WHERE cost is null; HTH, Marku -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org