日期:2014-05-19  浏览次数:20534 次

关于查找某个节点子节点的问题
找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)