Malcolm, Unfortunately SQL is not good at doing recursive code unless you use the Oracle version, so you have to approach the problem differently.
I have some VFP software that will help you in this. You can't so it in one SQL Query but you can make the problem really easy to crack if you approach it the right way. Rather than me try and explain I'll post a write-up and some sample code this evening. Dave Crozier -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Greene Sent: 08 October 2008 16:16 To: profox@leafe.com Subject: Hierarchical query I have have table with 2 columns: cParent and cChild. cParent may be a child of other cParents. Likewise cChild may be a cParent to other children. Is there a simple SQL query I can use to produce a list of all cParent children through an arbitary depth? Is there a way to capture the depth of each child so I could visually indent parent/child hierarchies? What happens if I have a circular reference, eg. a grandchild that has its top parent as a child? (in theory this shouldn't happen with my data, but ....) Thank you, Malcolm --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- [excessive quoting removed by server] _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.