如题

解决方案 »

  1.   

    http://hi.baidu.com/freedspaces/blog/item/d823efc4ac7b3ea98226ac1d.html
      

  2.   

    这个要用存储过程,在sql2000的帮助文件里有一个非常经典的类似存储过程,好象叫层次结构吧.你找找
      

  3.   

    数据库里
    得到目录树子级的所有的分类SET QUOTED_IDENTIFIER OFF 
    GO
    SET ANSI_NULLS OFF 
    GOCREATE function f_getChild(@ID VARCHAR(1000))
    returns @t table(ID int,parentid int,[Name] nvarchar(20) ,[Description] ntext, Icon nvarchar(60) , Visible bit,IsAggregated bit,myOrder int,AddTime datetime,UpdateTime datetime,Depth int,Level INT)
    as
    begin
        declare @i int
        set @i = 1
        insert into @t select ID,parentid,[Name],[Description],Icon,Visible,IsAggregated,myOrder,AddTime,UpdateTime,Depth,@i from vd_category a where parentid = @ID
        
        while @@rowcount<>0
        begin
            set @i = @i + 1
            
            insert into @t 
            select 
                a.[ID],a.parentid,a.[Name],a.[Description],a.Icon,a.Visible,a.IsAggregated,a.myOrder,a.AddTime,a.UpdateTime,a.Depth,@i
            from 
                vd_category a,@t b 
            where 
                a.parentid=b.ID and b.Level = @i-1
        end
        return
    end
    GO
    SET QUOTED_IDENTIFIER OFF 
    GO
    SET ANSI_NULLS ON 
    GO
      

  4.   

    其实很简单了,只要加一个字段就可以了分类表里面加一个字段:Path路径的意思,从根结点开始记录每一级的节点,就好像每个文件所在的文件夹的路径一样。比如:0  0
    1  0
    2  03  0,1
    4  0,1
    5  0,1,3
    6  0,1,3
    应该能够看出来吧,5的父节点是 3 ,5的父节点是 1 。0
      1
        3
          5
          6
        4
      2
    那么我想显示 1的所有节点,加一个 like 就可以了 , like '0,1%'。简单吧。
      

  5.   

    5的父节点是 3 ,5的父节点是 1 。 == 5的父节点是 3 ,3的父节点是 1 。(都是copy害的)
      

  6.   

    path like '0,1%' % 知道?模糊查询知道?唉,说的都够详细的了。不会就不会吧,
      

  7.   

    递归 ~~ 数据库中加 path  parentid 都OK
      

  8.   

    分二步:
    一:获取当前节点的所有子节点(包括子孙节点)的id 
    所有的id用","分隔(包括当前节点)
    二: select * from news where newstypeid in(2,5,7,9) 形式来获取
      

  9.   

    无限级分类的非递归实现并附ASP.NET事例
    http://hi.baidu.com/alby/blog/item/20bd33fae9c6181ea8d311b2.html