我有一个表的字段为ProductIdList,其值格式为11,24,28,32productIdlist11,24,28,32
10,24,27
24,32,54,73,75
05,08,25我想将该字段值中包涵了24的记录查询出来,最好能用一句SQL完成。
10,24,27
24,32,54,73,75
05,08,25我想将该字段值中包涵了24的记录查询出来,最好能用一句SQL完成。
解决方案 »
- 请帮忙看看存储过程为什么报错
- 如何查询某字段内是否包含 “'”
- 一个十分奇怪的问题 如何删除复制 发布
- 请教高手一个Reporting Service令人无语的问题?
- 查询每个类别第一条数据,很难(对我)
- 急救,create storeprocedure 现场给分。
- 列名为变量的查询问题
- 能否将accesss数据库关联到SQLServer中?
- sql7.0下动态自增字段,类似identity(hex,1,1),怎样实现?
- 如何使用SQl Server的debug 功能调试procedure.?
- 简单Sql常识问题,一直没有解决???
- delete一个表中的数据后,还能找回来吗?(sqlserver)
insert into @t select '11,24,28,32'
union all select '10,24,27'
union all select '24,32,54,73,75'
union all select '05,08,25'
union all select '05,08,25,244'declare @i int
set @i=24
select * from @t where charindex(','+cast(@i as varchar)+',',productIdlist)>0
select * from table1 where productIdlist like'%24%'
declare @t table(productIdlist varchar(20))
insert into @t select '11,24,28,32'
union all select '10,24,27'
union all select '24,32,54,73,75'
union all select '05,08,25'
union all select '05,08,25,244'declare @i int
set @i=24
select * from @t where charindex(','+cast(@i as varchar)+',',','+productIdlist+',')>0
where productIdlist like'%,24,%' or productIdlist like'24,%' or productIdlist like'%,24' 楼上也是一种好方法!!
insert into @t select '11,24,28,32'
union all select '10,24,27'
union all select '24,32,54,73,75'
union all select '05,08,25'
union all select '05,08,25,244'
union all select '05,08,25,24'declare @i int
set @i=24
select * from @t where charindex(','+cast(@i as varchar)+',',','+productIdlist+',')>0--修改以后应该可以了