Ron, It was that article (thank you) that caused me to pose the question. For the application I intend to apply this to, there needed to be a way to identify any element's immediate "superior". Jim Blackburn got me thinking in the right direction:
Table ------------- ID, lft,rgt ------------- ID1,1,12 ID2,4,11 ID3,7,8 sel ID from table whe lft = (sel max(t2.lft) from table t1, table t2 whe t2.lft < t1.lft and t2.rgt > t1.rgt and t1.ID = 'ID3') Ben Petersen On 8 Jan 2002, at 11:45, Ron Rose wrote: > I would try "Trees in SQL" in Google search. > http://www.intelligententerprise.com/001020/celko1_1.shtml > RRR > > Ben Petersen wrote: > > > > Hi all. Looking at the snippit of data records below, how would a > > person do a select that, using ID3 data, would return ID2 (and not > > ID1)? > > > > Working from the bottom up, you can count on the two numerics of > > each record being bounded by the next record, ie 4 and 11 of ID2 > > would enclose 7 and 8 of ID3... 1 and 12 of ID1 enclose 4 and 11 of > > ID2. > > > > So, if you only knew the values of ID3, how would you construct a > > select that only returned ID2? I can do it in two steps (I think), but > > would rather one. > > > > ID1,1,12 > > ID2,4,11 > > ID3,7,8 > > > > tia, > > > > Ben Petersen > > ================================================ > > TO SEE MESSAGE POSTING GUIDELINES: > > Send a plain text email to [EMAIL PROTECTED] > > In the message body, put just two words: INTRO rbase-l > > ================================================ > > TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] > > In the message body, put just two words: UNSUBSCRIBE rbase-l > ================================================ > TO SEE MESSAGE POSTING GUIDELINES: > Send a plain text email to [EMAIL PROTECTED] > In the message body, put just two words: INTRO rbase-l > ================================================ > TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] > In the message body, put just two words: UNSUBSCRIBE rbase-l > ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l
