Re: SQL help requested - "linked list"
From: --CELKO-- <joe.celko_at_northface.edu>
Date: 22 Aug 2003 14:12:00 -0700
Message-ID: <a264e7ea.0308221312.57332308_at_posting.google.com>
Date: 22 Aug 2003 14:12:00 -0700
Message-ID: <a264e7ea.0308221312.57332308_at_posting.google.com>
>> Given one of the ID values (they're unique), I want to select the
IDs
that occur before and after in that particular linked list. In a
differnet language I would approach this using a recursive function.
Is this possible in SQL? <<
Yes, but very ugly.
- Use a cursor and travel up and down the list, like a proceudral language
- Use a nested sets model for trees (google it) and allow only one child per parent node.