数据库是这样的:
有一张表:bbs_forums 其中有字段:fid(板块id),name(板块名),rootid(跟目录),depth(菜单级别),child(子菜单个数) 现在我想通过一个下拉框将其数据格式化的输出!
就如: >a
>a1
>a2
>b
>b1
>b2
>c
>c1
>c2
请问sql语句该如何写????
谢谢!
有一张表:bbs_forums 其中有字段:fid(板块id),name(板块名),rootid(跟目录),depth(菜单级别),child(子菜单个数) 现在我想通过一个下拉框将其数据格式化的输出!
就如: >a
>a1
>a2
>b
>b1
>b2
>c
>c1
>c2
请问sql语句该如何写????
谢谢!
from bbs_forums
where rootid is null
union all
select concat(' >', name),fid,rootid,fid as skey
from bbs_forums
where rootid is not null
order by 3,4
(
select concat('>', name),fid,fid as rootid,0 as skey
from bbs_forums
where rootid is null
union all
select concat(' >', name),fid,rootid,fid as skey
from bbs_forums
where rootid is not null
)
order by 3,4