首页 > 其他 > 详细

从字符串中提取数字

时间:2015-07-23 21:35:50      阅读:195      评论:0      收藏:0      [点我收藏+]

with n(str, ori, pos) as (
values (‘1,3533,3528,3657,‘, 1, locate(‘,‘,‘1,3533,3528,3657‘))
union all
select str, pos+length(‘,‘), locate(‘,‘, str, pos+length(‘,‘))
from n
where locate(‘,‘, str, pos+length(‘,‘))>0) ,
tmp as (
select substr(str, ori, pos-ori) as trmnlId from n)
select INT(trmnlId) from tmp;

 

 locate(‘,‘,‘1,3533,3528,3657‘)返回‘,‘在‘1,3533,3528,3657‘中第一次出现的位置

 

从字符串中提取数字

原文:http://www.cnblogs.com/ren-shi-min/p/4671467.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!