Since we will look at ORACLE recursive queries, we should be clear about what recursion means. Here I will not explain it more, but I will just give a brief introduction.
The so-called recursive query makes the data structure in the data table conform to the basic conditions of recursive query, that is, the table has the ID and PID (node number, parent node number) if the data is displayed in the UI, it should be one or more trees.
We need to explain the process of recursively querying the child or parent node of this node with one node.
Recursive query syntax:
Where condition 4
The table structure http://www.cnblogs.com/wanghonghu/archive/2012/08/31/2665945.html below
() (( BYTE) ()
); SC_DISTRICT SC_DISTRICT SC_DISTRICT (IID));
SC _DISTRICT (IID, INAME) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ) (, SC _DISTRICT (IID, PARENT_ID, INAME, BZ )(,,);
If
-- Query subnodes in Pyeongchang County
SELECT * FROM SC _DISTRICT
Start with iname = 'pyeongchang Sha'
Connect by prior iid = PARENT_ID
-- Query the parent node of Pyeongchang County
SELECT * FROM SC _DISTRICT
Start with iname = 'pyeongchang Sha'
Connect by prior PARENT_ID = IID
-- Only filters out subnodes whose node BZ is 0, but does not filter out subnodes whose node BZ is 0 (this is worth noting ),
-- Currently, you can filter subnodes whose BZ is 0.
SELECT * FROM SC _DISTRICT WHERE BZ = 0
Start with iname = 'pyeongchang Sha'
Connect by prior PARENT_ID = IID
-- This method not only filters out nodes with BZ 0, but also does not traverse the subnodes of this node.
SELECT * FROM SC _DISTRICT START WITH INAME = 'pyeongchang County'
Connect by prior PARENT_ID = iid and bz = 0
If you know more about recursive methods, the above methods are easy to understand.