当前位置: 代码迷 >> J2SE >> 查找根结点下的所有节点解决方案
  详细解决方案

查找根结点下的所有节点解决方案

热度:228   发布时间:2016-04-24 01:39:52.0
查找根结点下的所有节点
查找根结点下的所有节点

递归的方法   怎么才能把这个节点下的   所有节点查出来


------解决方案--------------------
以下是DB2的例子
SQL code
WITH test(parentid,id,name) AS(       VALUES       (-1,0,'root'),       (0,1,'----branch1'),       (1,11,'--------branch11'),       (11,111,'------------branch111'),       (111,1111,'----------------branch1111'),       (111,1112,'----------------branch1112'),       (11,112,'------------branch112'),       (1,12,'--------branch12'),       (0,2,'----branch2'),       (2,21,'--------branch21')),       temp(parentid,id,name) AS(       SELECT parentid,id,name FROM test WHERE name='root'       union all       SELECT t1.parentid,t1.id,t1.name FROM test t1,temp t2 WHERE t1.PARENTID=t2.id       )       SELECT name FROM temp
------解决方案--------------------
循环加递归么~
  相关解决方案