[此贴子已经被作者于2006-6-28 7:40:15编辑过]
declare @A5_WXMcls table
(
sXMCode varchar(5),
sXMName varchar(10),
lXMGrade int
)
insert into @A5_WXMcls
select '01','幻灵游侠',1 union all
select '01001','官网',2 union all
select '02','征服',1 union all
select '03','霸王大陆',1 union all
select '04','魔兽世界',1 union all
select '01002','私服',2
declare @X5_YtaskNumber table
(
sCode varchar(9),
dDate varchar(10),
sXMCode varchar(2)
)
insert into @X5_YtaskNumber
select '200511001','2005-11-25','01' union all
select '200511002','2005-11-26','02'
select * from @A5_WXMcls
select * from @X5_YtaskNumber
select space((lXMGrade-1)*4)+sXMName
from @A5_WXMcls a,@X5_YtaskNumber b
where charindex(','+b.sXMCode,','+a.sXMCode)<>0
order by a.sXMCode
/*
sXMCode sXMName lXMGrade
------- ---------- -----------
01 幻灵游侠 1
01001 官网 2
02 征服 1
03 霸王大陆 1
04 魔兽世界 1
01002 私服 2
sCode dDate sXMCode
--------- ---------- -------
200511001 2005-11-25 01
200511002 2005-11-26 02
-----------
幻灵游侠
官网
私服
征服
*/
[此贴子已经被作者于2006-6-28 13:39:01编辑过]
where charindex(','+b.sXMCode,','+a.sXMCode)<>0
不要这句行吗?
如果是有三级,四级。。。呢?
以下应该就行了把(参考楼上代码):
declare @A5_WXMcls table
(
sXMCode varchar(8),
sXMName varchar(10),
lXMGrade int
)
insert into @A5_WXMcls
select '01','幻灵游侠',1 union all
select '01001','官网',2 union all
select '01002','官网',2 union all
select '01003','官网',2 union all
select '01001001','官网',3 union all
select '01001002','官网',3 union all
select '02','征服',1 union all
select '03','霸王大陆',1 union all
select '04','魔兽世界',1 union all
select '01002','私服',2
select space((lXMGrade-1)*4)+sXMName
from @A5_WXMcls
order by sXMCode