Syntax: Connect by is used in structured queries with the following basic syntax:
Start With,connect by main purpose: Remove the tree data from the table. Each piece of data that can be assumed to be stored in a table is a node in the tree, respectively.
Select ... from tablename start with condition 1connect by prior condition 2where condition 3; wherein: Condition 1 is the root node limit statement, of course, can also relax the limited conditions to take multiple nodes, forming multiple trees. Condition 2 is the join condition. Condition 3 is the filter condition that is used to filter all records returned. For example SELECT * from Tablestart with id = ' G113 ' connect by Prior id = pidwhere Fflag = ' Y '; There are two fields, IDs and PID in a tree-like storage table. Where PID is the ID of the ID ancestor record. All records of this tree can be obtained by querying the above syntax. Scan Order: 1, starting from the root node, 2, accessing the node, 3, judging the node has no access to the sub-node, if any, then to its leftmost non-visited sub-node, and perform the second step, otherwise perform the fourth step; 4, if the node is the root, then access is complete, otherwise fifth step; 5, Returns the parent node of the node and executes the third step; Select ... connect by {Prior column name 1 = column name 2| column name 1=prior column name 2}[start with];
Using the Connect by PRIOR START with statement in Oracle