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.
- Select * from TEST
- Start with id = 1
- Connect by prior id = pid
- 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.