Recursively determine parent records?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

Hi All,

 

I have recordset that contains a hierarchical representation of records
where a record's [parentid] field contains the recid of the record 'above'
the current record.

 

A representation might look like this:

 

Recid, parentid, title

 

1, 0, Top level record

2, 0, Another top level record

3, 1, A record under the top level record

4, 3, Another level

5, 2, A record under the second top level record

 

If I have currently retrieved the record with recid of 4, I want to work out
the 'chain' of records that lead back to the top level record it has been
created under.

 

In this instance, that chain would look like:

 

4, 3, Another level

3, 1, A record under the top level record

1, 0, Top level record

 

I'm wondering if anyone can help me work out how to achieve this?

 

Many thanks in advance!

 

Much warmth,

 

Murray

 <http://www.planetthoughtful.org/> http://www.planetthoughtful.org

Building a thoughtful planet,

One quirky comment at a time.

 


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux