sql递归获取所有子节点
1个回答
2013-06-08
展开全部
假如表数据如下:
t_id p_id node
1 <null> a
2 1 b
3 1 c
4 2 d
5 2 e
树的形状为
a
| \
b c
| \
d e
递归代码为:select t_id, p_id, node from tree
connect by prior t_id = p_id
start with t_id = 1
t_id p_id node
1 <null> a
2 1 b
3 1 c
4 2 d
5 2 e
树的形状为
a
| \
b c
| \
d e
递归代码为:select t_id, p_id, node from tree
connect by prior t_id = p_id
start with t_id = 1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询