Suppose I have a self-referential table as follows:
ID Name Ref_ID
--------------------
01 Michel 00
02 Tom 01
03 Arnon 01
04 Scot 02
05 David 02
06 John 03
07 Bill 03
08 Alistair 05
Where Ref_ID basically points to the person's 'sponsor' or
the person who referred the first person (like in a multi-level marketing scenario).
Now, say I wanted to get the IDs of sponsors for 'Alistair' all the way up to Michel (id 00 means no sponsor). This should be:
Alistair: 08, 05, 02, 01
Can this be done in one SQL statement? In one FoxPro statement? As in, one statement. No calls to stored procedures or functions, no compound statements or what.
Just curious...
alistair israel
Distressed DBA, Sleepy SysAd, Weary WebMaster (aka Senior Software Engineer)
aisrael@poboxes.com
Makati City, Philippines