递归查询

参考:  https://www.cnblogs.com/chen1388/archive/2010/09/25/1834827.html

sql:

select t.* from cms_org_relation t start with t.org_id = '199570057205'
connect by prior t.org_id = t.parent_org order siblings by t.create_time; 

说明: 

    start with  : 遍历起始条件

 connect by  : 连接条件

           prior  : 表示上一条记录,比如 prior t.org_id = t.parent_org 就是说上一条记录的 【org_id】 是本条记录的 【parent_org】,即本记录的父亲是上一条记录。 

查询结果:

『愿你我既可以朝九晚五,又能够浪迹天涯』
原文地址:https://www.cnblogs.com/zjwwljty/p/8073579.html