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 6590F9DCA83 for ; Tue, 28 Mar 2006 13:34:26 -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 15425-03 for ; Tue, 28 Mar 2006 13:34:22 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smarty.gabriel.co.hu (smarty.gabriel.co.hu [195.70.37.16]) by postgresql.org (Postfix) with ESMTP id BBF199DCA3E for ; Tue, 28 Mar 2006 13:34:19 -0400 (AST) Received: from localhost (smarty [127.0.0.1]) by smarty.gabriel.co.hu (Postfix) with ESMTP id A795E417AB for ; Tue, 28 Mar 2006 19:34:15 +0200 (CEST) Received: from smarty.gabriel.co.hu ([127.0.0.1]) by localhost (smarty [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 09220-06-4 for ; Tue, 28 Mar 2006 19:34:15 +0200 (CEST) Received: from [192.168.111.135] (customer-174.radio-net.hu [217.113.54.174]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smarty.gabriel.co.hu (Postfix) with ESMTP id 8639541799 for ; Tue, 28 Mar 2006 19:34:15 +0200 (CEST) Message-ID: <4429739F.6020205@i-logic.hu> Date: Tue, 28 Mar 2006 19:34:23 +0200 From: =?ISO-8859-1?Q?G=E1briel_=C1kos?= Organization: I-Logic Kft User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Update question References: <00b801c65286$7ca8f260$b8d849c6@versaterm.com> <442969AB.2020604@logix-tt.com> In-Reply-To: <442969AB.2020604@logix-tt.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gabriel.co.hu X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.074 required=5 tests=[AWL=0.074] X-Spam-Score: 0.074 X-Spam-Level: X-Archive-Number: 200603/447 X-Sequence-Number: 24793 Markus Schaber wrote: > 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 > This is ok, but this is redundant, i guess. you should put edge_id and cost into another table and use join to retrieve cost for each id. put a key on edge_id, most likely a primary (unique) key. -- Üdvözlettel, Gábriel Ákos -=E-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=- -=Tel/fax:+3612367353 |Mobil:+36209278894 =-