I have a table that represents a tree structure via a self-join. I'd
like to get hold of all parent records in a single query - is such a
thing possible? e.g. given
id parentid
1 0
2 1
3 2
4 2
5 1
6 4
If I was starting with record 4, I would want it to return records 2
and 1 (probably in that order), starting from 5 would just give me 1
etc. It needs to support arbitrary depth, hence the need for recursion.
Can I do this in one go, or do I have to query iteratively until I
encounter a zero reference?
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@stripped | http://www.synchromedia.co.uk