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.