An Oracle query to the parent node from a child node ____oracle

Source: Internet
Author: User

Today, a person in the department asked me how to trace from a child node record to a parent node in Oracle. For example, there is a table:

GUID Parentguid

1 0

2 1

3 1

4 2

5 2

6 5

7 5

8 7

We can detect all the child nodes under the GUID from the GUID 1 according to the parentguid relationship.

Now to find out its parent node, the 7->5->2->1 relationship, from a child node such as GUID 7.

In fact, this is a very funny question, if you can detect child nodes from the parent node, then, in turn, the GUID of the child node as the parent node of the Parentguid

The child node becomes the parent node. So

Select GUID from test start and GUID =7 connect by prior Parentguid = GUID

That can detect the relationship between 7->5->2->1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.