表tab中的aa列如下:
asdfdsf?d=123&ewv
qwer?d=234
asfdwe?d=234&dhewu
adfasf?d=25&reuw
afhkashf
如何获取这些里的值d=123,d=234,d=25,求大神指导
1、创建测试表,
create table test_int(value varchar2(50));
2、插入测试数据
insert into test_int values('asdfdsf?d=123&ewv');
insert into test_int values('qwer?d=234');
insert into test_int values('asfdwe?d=234&dhewu');
insert into test_int values('adfasf?d=25&reuw');
insert into test_int values('afhkashf');
commit;
3、查询表中全量数据,select t.*, rowid from test_int t;
4、编写sql,获取字符串中的指定字符;
select t.*,
case
when instr(value, 'd=') = 0 then
null
else
substr(value,
instr(value, 'd='),
case
when instr(value, '&') = 0 then
10
else
instr(value, '&') - instr(value, 'd=')
end)
end a
from test_int t;
用函数实现会比较方便,如果是SQL Server的话,可以创建如下函数:
create function dbo.get01 (@s nvarchar(1000))调用示例:
select s.txt, dbo.get01(s.txt) as val结果:
本回答被提问者采纳这个根本就不能用