declare @a table (id int,name varchar(10),channel int)
insert into @a select 1,'汽车',5
insert into @a select 2,'火车',6
insert into @a select 3,'飞机',7
insert into @a select 4,'轮船',8
insert into @a select 5,'火箭',9
declare @b table (id int,fatherid int,childids varchar(10),name varchar(10))
insert into @b select 1,0,'1,5,6','陆地工具'
insert into @b select 2,0,'2,7,9','飞行工具'
insert into @b select 3,0,'3,8,4','水上工具'
insert into @b select 4,3,'4','船只'
insert into @b select 5,1,'5','机动车'insert into @b select 6,1,'6','铁路'
insert into @b select 7,2,'7','飞行器'
insert into @b select 8,3,'8','水上运输'
insert into @b select 9,2,'9','航空航天'select * from @a a,@b b 
where charindex(','+ltrim(a.channel)+',',','+b.childids+',')>0
id name channel id fatherid childids name
1 汽车 5 1 0 1,5,6 陆地工具
2 火车 6 1 0 1,5,6 陆地工具
3 飞机 7 2 0 2,7,9 飞行工具
5 火箭 9 2 0 2,7,9 飞行工具
4 轮船 8 3 0 3,8,4 水上工具
1 汽车 5 5 1 5 机动车
2 火车 6 6 1 6 铁路
3 飞机 7 7 2 7 飞行器
4 轮船 8 8 3 8 水上运输
5 火箭 9 9 2 9 航空航天