易截截图软件、单文件、免安装、纯绿色、仅160KB

菜鸟求一SQL语句,显示同一表内三级栏目列表



表结构如图

cid      int    栏目ID
fatherid  int    父栏目ID
childid  text    子栏目ID
childids  text    所有下级栏目ID
deeppath  int    栏目层次
name      varchar 栏目名称

求一SQL语句,显示同一表内三级栏目列表,效果如下:

一级栏目-1  二级栏目-1  三级栏目-1
一级栏目-1  二级栏目-1  三级栏目-2
一级栏目-2  二级栏目-2  三级栏目-3
一级栏目-2  二级栏目-2  三级栏目-4
一级栏目-2  二级栏目-3  三级栏目-5


 


没看懂

还是我发错版块了??? ^_^

树形结构,图的问题,学习中

SQL code:
declare @t table(id int,fatherid int,name varchar(10))
insert @t select 9,0,'一级栏目-1'
insert @t select 10,9,'二级栏目-1'
insert @t select 11,10,'三级栏目-1'
insert @t select 12,10,'三级栏目-2'
insert @t select 13,0,'一级栏目-2'
insert @t select 14,13,'二级栏目-2'
insert @t select 15,14,'三级栏目-3'
insert @t select 16,14,'三级栏目-4'
insert @t select 17,13,'二级栏目-3'

select a.name,b.name,c.name
from @t a
right join @t b on a.id = b.fatherid
left join @t c on b.id = c.fatherid
where a.fatherid = 0


name name nam


相关问答:

求一sql语句 - MS-SQL Server / 基础类


id bh  
1 10
2 11
3 12 
4 15
5 16
6 22
7 25
8 26
9 27
10 28
将bh按连续分段出来返回字符串:
10~12,15~16,22,25~28
SQL code:


declare @t tabl ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

关于SQL Server Mobile Edition - .NET技术 / C#

关于SQL Server Mobile Edition
用Microsoft SQL Server2005 Management Studio Express9.00.3042.00创建SQLCE数据库sqlmobile.sdf
在mobile系统终端上用SQL Server Mobile Edition3.0能查看sqlmobile.sdf里表数据 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号