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 312D89DC9EF for ; Tue, 28 Mar 2006 14:33:21 -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 27405-07 for ; Tue, 28 Mar 2006 14:33:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.versaterm.com (smtp.versaterm.info [216.208.41.121]) by postgresql.org (Postfix) with ESMTP id 31C0A9DC948 for ; Tue, 28 Mar 2006 14:33:15 -0400 (AST) Received: from fay (unknown [198.73.216.184]) by smtp.versaterm.com (Postfix) with ESMTP id 30B2470006; Tue, 28 Mar 2006 13:33:10 -0500 (EST) From: "Fay Du" To: =?iso-8859-1?Q?'G=E1briel_=C1kos'?= , Subject: Re: Update question Date: Tue, 28 Mar 2006 13:33:02 -0500 Message-ID: <00c301c65296$0c21c6b0$b8d849c6@versaterm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <4429739F.6020205@i-logic.hu> x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.095 required=5 tests=[AWL=0.095] X-Spam-Score: 0.095 X-Spam-Level: X-Archive-Number: 200603/448 X-Sequence-Number: 24794 Markus and G=E1briel: Thank you very much for the help. Yes, the table is redundant. What I am trying to do is using pgdijstra module from postGIS which is on the top of postgreSQL. And the module asks for entire network is directional or non-directional. But my network part is directional and other part is non-directional. I made it is directional by duplicate all non-directional edges into 2 directional edges and it is where redundant come from. And the module only accept data from one table, so I have to keep all data in one table. Thanks again. Fay -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of G=E1briel =C1kos Sent: Tuesday, March 28, 2006 12:34 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Update question Markus Schaber wrote: > Hi, Fay, >=20 > 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 >=20 >> 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. >=20 > It should go like: >=20 > UPDATE cost SET edge_id =3D (SELECT cost FROM cost innr WHERE innr.edge_id > =3D edge_id AND innr.cost is not null) WHERE cost is null; >=20 > HTH, > Marku >=20 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. --=20 =DCdv=F6zlettel, G=E1briel =C1kos -=3DE-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=3D- -=3DTel/fax:+3612367353 |Mobil:+36209278894 =3D- ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly