X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4641611F60E8 for ; Wed, 26 Apr 2006 14:18:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 58126-01 for ; Wed, 26 Apr 2006 14:18:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp4.pacifier.net (smtp4.pacifier.net [64.255.237.174]) by postgresql.org (Postfix) with ESMTP id E8F0811F60AF for ; Wed, 26 Apr 2006 14:18:08 -0300 (ADT) Received: from nefesh (ip16.gte154.dsl-acs2.sea.iinet.com [207.202.154.16]) by smtp4.pacifier.net (Postfix) with SMTP id A8EA875717 for ; Wed, 26 Apr 2006 10:18:05 -0700 (PDT) From: "Ray Madigan" To: "Pgsql-Sql" Subject: Re: LinkedList Date: Wed, 26 Apr 2006 10:35:15 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <1146067158.23538.264.camel@state.g2switchworks.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.449 tagged_above=0 required=5 tests=AWL, BAYES_00, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: X-Archive-Number: 200604/183 X-Sequence-Number: 24992 Scott, Thanks for your reply, I tried what you said, worked around a few things but I am still stuck. The main reason is I didn't do an adequate job of explaining the situation. The table implements many linked lists and I want to traverse one of them given the end of the list. Say the table contains h | v | j 1 0 100 3 1 300 5 3 500 7 5 700 2 0 200 4 2 400 6 4 600 8 6 800 If I specify t.h = 8 I want to traverse the even part of the table If I specify t.h = 7 I want to traverse the odd part of the table If you can send me to a book to read I am willing Thanks -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Scott Marlowe Sent: Wednesday, April 26, 2006 8:59 AM To: Ray Madigan Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] LinkedList On Wed, 2006-04-26 at 11:09, Ray Madigan wrote: > I have a table that I created that implements a linked list. I am not an > expert SQL developer and was wondering if there are known ways to traverse > the linked lists. Any information that can point me in the direction to > figure this out would be appreciated. The table contains many linked lists > based upon the head of the list and I need to extract all of the nodes that > make up a list. The lists are simple with a item and a link to the history > item so it goes kind of like: > > 1, 0 > 3, 1 > 7, 3 > 9, 7 > ... > > Any suggestions would be helpful, or I will have to implement the table > differently. You should be able to do this with a fairly simple self-join... select a.id, b.aid, a.field1, b.field1 from mytable a join mytable b on (a.id=b.aid) Or something like that. ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster