在一个字段里比较大小???急
时间:2011-12-24
来源:互联网
在一个字段里有
序号 价格
1 100,150,400,450,668
2 350,510,600,750,768
3 250,450,460,550,668
我想查出价格在 200-400之间的,或300-500之间的,也可能是100-500
求高手????
序号 价格
1 100,150,400,450,668
2 350,510,600,750,768
3 250,450,460,550,668
我想查出价格在 200-400之间的,或300-500之间的,也可能是100-500
求高手????
作者: oolinyu 发布时间: 2011-12-24
先拆分,再查询.
作者: qianjin036a 发布时间: 2011-12-24
SQL code
create table tb(序号 int,价格 varchar(20)) insert into tb select 1,'100,150,400,450,668' insert into tb select 2,'350,510,600,750,768' insert into tb select 3,'250,450,460,550,668' go declare @min int,@max int set @min=200 set @max=400 --你可以改变这两个值 select distinct 序号 from( select a.序号,substring(a.价格,b.number,charindex(',',a.价格+',',b.number+1)-b.number)价格 from tb a,master..spt_values b where b.type='p' and b.number<=len(a.价格) and substring(a.价格,b.number,1)<>',' and substring(','+a.价格,b.number,1)=',' )t where 价格 between @min and @max /* 序号 ----------- 1 2 3 (3 行受影响) */ go drop table tb
作者: qianjin036a 发布时间: 2011-12-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28