标签:
要实现的树如图所示,要求能根据“节点1”获取其所有子节点
数据库表设计如下:
在这里用到With As
WITH tb AS { SELECT* FROM node WHERE nodeId=1 UNION ALL SELECT node.nodeId,node.nodeName,node.parentId FROM node,tb WHERE node.parentId=tb.nodeId } SELECT * FROM tb
标签:
原文地址:http://www.cnblogs.com/ecosu/p/4285796.html