DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: family tree

  1. #1
    Join Date
    Dec 2000
    Posts
    95

    Question

    Hi ,

    I have small Question.

    Using "start with " and "connect by" we can get the hierarchical results. Thats fine.

    But how can I control the navigation flow from root to leaf and leaf to root.

    Suppose take an instance of the following query

    select groupid,parentid from groups start with groupid= connect by parentid = prior groupid;

    (groups is a table having groupid,parentid columns)

    If I replace the "" to root groupid, it gives the hierarchy from root to leaf. And if I replace the "" to leaf groupid, it gives the hierarchy from leaf to root.

    But if I replace "" to some of the middle group(its not root and its not leaf, its there middle in the hierarchy and it has children ) , then it gives the hierarchy from that group to leaf of that group.

    But I want the result like it has to show the results in a hierarchy from that group to root group(I mean its parent groups, not the child groups).

    How we can control this flow from the above the query?

    Thank you for any help

    Srinivas M

  2. #2
    Join Date
    Dec 2000
    Posts
    95
    Hi,

    I got the answer.


    select groupid,parentid from group_info start with
    groupid= connect by prior parentid = groupid;


    this gives the hierarchy from any level to root.


    Thank you

    Srinivas M


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width