oracle sql recursive query

Encountered such a scenario during the project, a table is a parent-child structure table, and the association relationship depends on FATHER_ID to associate to form a tree-like rhythm. Now that the id of a node is known, all child nodes are queried. The oralce database provides a method. Pass the id in and query all substructures.
Our project is required for permission control query. A material belongs to a category, and the category id value can be the id of any node in any category structure tree. Then, when querying materials by category, I know the id of a category, and I must query this For all materials under the classification, a tree query method is required at this time to query all the classification ids of the subordinates

#######Don’t say much, just go to slq! ######

select * from   BASE_INFO E
where 1=1 
.....
.....
<if test="id != null and id != ''">
            AND EXISTS(SELECT* FROM (select * from ASSET_CLASS_INFO  start with id=#{id}
            connect by prior id = FATHER_ID) B WHERE E.EQU_CATEGORY_ID =B.ID)
        </if>

Guess you like

Origin blog.csdn.net/wujian_csdn_csdn/article/details/107510483