declare @s nvarchar(100) set @s='2,3,4' select * from T where charindex(','+rtrim(COL)+',',@s)>0
declare @s nvarchar(100) set @s='2,3,4' select * from T where ','+@s+',' like '%,'+rtrim(COL)+',%'或 select * from T where charindex(','+rtrim(COL)+',',','+@s+',')>0--或用patindex
set @s='2,3,4'
select * from T where charindex(','+rtrim(COL)+',',@s)>0
set @s='2,3,4'
select * from T where ','+@s+',' like '%,'+rtrim(COL)+',%'或
select * from T where charindex(','+rtrim(COL)+',',','+@s+',')>0--或用patindex
相反,我是遍历用逗号分隔的字符串,再把值插入数据库的.
即本来字符串是2,4,6 我插入表里是
typeid
2
4
6现在的问题是,假如我修改了字符串为2,3,4
那表里应该是
typeid
2
3
4