日期:2014-05-16 浏览次数:20470 次
select t_.a, t_.b, t_.c from ( select 1 as a, 8978 as b, 0 as c from dual union select 2, 777, 1 from dual union select 3, 666, 2 from dual union select 4, 78945, 2 from dual union select 5, 1234, 1 from dual union select 6, 4678, 1 from dual ) t_ -- t_.a = ? 通过修改'?'的值来取,所有a=?的子结点,以及子结点的子结点。 start with t_.a = 2 connect by prior t_.a = t_.c; /* output 1 2 777 1 2 3 666 2 3 4 78945 2 */
-- 把'='两端的对调过来。表示取a=?为子结点的根结点,以及根结点的根结点。 connect by prior t_.c = t_.a; /* output 1 2 777 1 2 1 8978 0 */