如一个表:
id 用户名串
1 w1,w2,w3
2 w1,w4,w5
3 w2,w3,w4如给一个参数,值是w1,请问怎样列出包含有w1的行,我用:
select id from table1 where w1 in 用户名串但是行不通
id 用户名串
1 w1,w2,w3
2 w1,w4,w5
3 w2,w3,w4如给一个参数,值是w1,请问怎样列出包含有w1的行,我用:
select id from table1 where w1 in 用户名串但是行不通
where 'W1' in (''''+replace(用户名串,',',''','''+'''')
set @str='W1'
select * from 表名 where charindex(','+@str+',',','+用户名串+',')>0select * from 表名 where ','+用户名串+',' like '%,'+@str+',%'