读书人

关于查找某个节点子节点的有关问题

发布时间: 2012-03-19 22:03:05 作者: rapoo

关于查找某个节点子节点的问题
找2,5,7文件夹的所有子文件夹
folderid, pid, fullpath分别表示文件夹标识号,直接父节点,完整路径.

select * from Folders
where
folderid in
(
select folderid from Folders
where
fullpath like
(
select fullpath + '/% '
from Folders
where folderid in(2,5,7)
)
)

[解决办法]
/*节点问题好象用函数比较好
去看看这个帖可能对你有帮助*/
http://community.csdn.net/Expert/topic/5648/5648651.xml?temp=.1318781
[解决办法]

select *
from Folders
where fullpath like (select fullpath + '/% ' from Folders where folderid=2)

union

select *
from Folders
where fullpath like (select fullpath + '/% ' from Folders where folderid=5)

union

select *
from Folders
where fullpath like (select fullpath + '/% ' from Folders where folderid=7)

读书人网 >SQL Server

热点推荐