Procedure for Oracle recursive condition Query

Source: Internet
Author: User

The following articles mainly introduce Oracle recursive condition query. The first thing we need to do is to make a related plan for the relevant tables, is the PID parent ID that must have its own ID and ID corresponding to the relevant record ). Its simple data structure is as follows,

Id pid

1 0

2 0

3 1

4 1

5 2

6 2

7 3

8 4

9 5

For example, you need to retrieve all the records whose ID is 1, such:

Id pid

1 0

3 1

4 1

7 3

8 4

The query statement is as follows:

Assume that the table name is test.

 
 
  1. Select * from TEST
  2. Start with id = 1
  3. Connect by prior id = pid
  4. Order by id asc

If conditional statements, such as where or when, are placed before start. OK.

The above content describes Oracle recursive condition queries, hoping to help you in this regard.


The above content describes Oracle recursive condition queries, hoping to help you in this regard.

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.