本帖最后由 shangxb2011 于 2010-12-13 15:55:47 编辑

解决方案 »

  1.   

    一个一级菜单和二级菜单的表
    type “1” 为一级菜单
    type“2” 为二级菜单
      

  2.   

    是要这个吗?
    create table tbmenu(id int,Menuname nvarchar(10),pid int,pidall nvarchar(10),type int)
    insert into tbmenu select 7,'a',1,'1',1
    insert into tbmenu select 8,'ab',7,'1,8',2
    insert into tbmenu select 3,'b',1,'1',1
    insert into tbmenu select 4,'ba',3,'1,3',2
    insert into tbmenu select 5,'c',1,'1',1
    insert into tbmenu select 6,'ca',5,'1,5',2
    go
    select menuname,(select menuname from tbmenu where type=2 and pid=a.id)as submenu from tbmenu a where type=1
    go
    drop table tbmenu
    /*
    menuname   submenu
    ---------- ----------
    a          ab
    b          ba
    c          ca(3 行受影响)*/