不用分割,
你试试
select * from t2 where id in (select user-grant from t1 where id = '1' )
这样应该可以把t2中符合t1中id为1的纪录的相应纪录取到
你试试
select * from t2 where id in (select user-grant from t1 where id = '1' )
这样应该可以把t2中符合t1中id为1的纪录的相应纪录取到
如果t1的id不是固定的,那么就要用列转换成行的方法将charindex的第二个参数变成一个字符
或者通过 存储过程 循环来实现
这样似乎不行的,这样取出的结果是 t2表 id 等于 t1表user-grant的记录
因为 select user-grant from t1 where id = '1' 取出来的user-grant是个整体,读sql的in来说是最小单位了
id 字段1 user——grant
1 A 1,2,3,4
2 B 2,3
3 C 2,4
4 D 1,4
5 E 1,3,4 t2
id 字段1 字段2
1 A a
2 B b
3 C c
4 D d
5 E e 假设 ID= "1"
select * from t2
where charindex(id,(select user——grant from t1 where id='"+ID+"') >0
and exists(select * from t1 where id='"+ID+"')
on charindex(','+b.id+',',','+a.user_grant+',')>0
inner join t1 on
charindex(',' + t2.ID + ',' , ',' + t1.user——grant + ',') > 0
where 你的其他条件
顺便问一个小小的问题啊,点击treeview父节点的时候,怎么样展开子节点啊?
不是点那个+号,是点text的内容
int对于charindex函数的参数1无效