首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

字段中有数组如何查询

2012-03-01 
字段中有数组怎么查询?有很多记录每个记录里有个字段(存放的是数组的值[如:1,2,3,4,5,6])目前要查出数组值

字段中有数组怎么查询?
有很多记录每个记录里有个字段(存放的是数组的值[如:1,2,3,4,5,6])   目前要查出数组值里必须都大于3的所有记录(比如:5,5,5,5,5,5   或   5,6,4,6,5,6)
请问怎么写WHERE???

[解决办法]
declare @a table(a varchar(100))
insert @a select '1,2,3,4,5,6 '
union all select '5,5,5,5,5,5 '
union all select '5,6,4,6,5,6 '

select * from @a where patindex( '%[0-3]% ',a)=0

[解决办法]
select * from @a where patindex( '%,[0-3],% ', ', '+a+ ', ')=0
union
select * from @a where patindex( '[0-3],% ',a+ ', ')=0
union
select * from @a where patindex( '%,[0-3] ', ', '+a)=0

试试

热点排行
Bad Request.