From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
---|---|
To: | Ray Madigan <ray(at)madigans(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: LinkedList |
Date: | 2006-04-26 15:59:18 |
Message-ID: | 1146067158.23538.264.camel@state.g2switchworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Ray Madigan | 2006-04-26 16:09:56 | LinkedList |
Previous Message | Markus Schaber | 2006-04-26 08:10:26 | Re: Migrating a Database to a new tablespace |