Oracle SQL:获取两句话之间的文本
我试图从存储在名为“myColumn”的表列中的字符串中提取一组字符串,其中一行如下所示-Oracle SQL:获取两句话之间的文本,oracle,substring,Oracle,Substring,我试图从存储在名为“myColumn”的表列中的字符串中提取一组字符串,其中一行如下所示- Type:MOBILE Service:GSM Pd to LOOK: NOKIA/HMD; APPLE; MI; Pd to SEE (swap): SAMSUNG; VIVO; Pd to SEE (extra): MOKA; Contact me: 123456 我尝试获取一列的代码是- SELECT regexp_substr(myColumn, '\"Products to be CEA
Type:MOBILE
Service:GSM
Pd to LOOK:
NOKIA/HMD;
APPLE;
MI;
Pd to SEE (swap):
SAMSUNG;
VIVO;
Pd to SEE (extra):
MOKA;
Contact me: 123456
我尝试获取一列的代码是-
SELECT regexp_substr(myColumn, '\"Products to be CEASED:"([^"Products to be PROVIDED (swap):"]+)\}', 1,1,NULL,1) AS output FROM mytable
我需要一个可以返回句子之间文本的查询-
“Pd要查看:”和“Pd要查看(交换):”
“Pd-to-SEE(交换):”和“Pd-to-SEE(额外):”
“Pd要查看(额外):”和“联系我:123456”
比如说-
Pd to LOOK: Pd to SEE (swap): Pd to SEE (extra):
NOKIA/HMD; APPLE; MI; SAMSUNG;VIVO; MOKA;
直接的解决方法是将substr函数与instr函数结合使用。或DBMS_LOB.instr和substr(如果列的数据类型是LOB) 例如:
select
substr(
mycolumn,
instr(mycolumn,'Pd to LOOK:'), --starting position
instr(mycolumn,'Pd to SEE (swap):') - instr(mycolumn,'Pd to LOOK:'), --amount to get
) as "Pd to LOOK:"
--, other expressions/columns
from
my_table;
直接的解决方法是将substr函数与instr函数结合使用。或DBMS_LOB.instr和substr(如果列的数据类型是LOB) 例如:
select
substr(
mycolumn,
instr(mycolumn,'Pd to LOOK:'), --starting position
instr(mycolumn,'Pd to SEE (swap):') - instr(mycolumn,'Pd to LOOK:'), --amount to get
) as "Pd to LOOK:"
--, other expressions/columns
from
my_table;