SQL中怎样获取这个字段的一部分

如图,现在要获取oid字段的第一个点和第二个点之间的部分,怎么实现。Oracle数据库

第1个回答  2014-11-10
select substr(oid,instr(oid,'.')+1,instr(oid,'.',instr(oid,'.') + 1) - instr(oid,'.') -1 ) from tabname;
第2个回答  推荐于2017-10-02
语句:
select substr(oid,instr(oid,'.')+1,(instr(oid,'.',1,2)-instr(oid,'.')-1) from table1;

函数:
1.INSTR(C1,C2,I,J)
在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
C1 被搜索的字符串
C2 希望搜索的字符串
I 搜索的开始位置,默认为1
J 出现的位置,默认为1
SQL> select instr('oracle traning','ra',1,2) instring from dual;
INSTRING
---------------------------------------
9
2.SUBSTR(string,start,count)
取子字符串,从start开始,取count个
SQL> select substr('13088888888',3,8) from dual;
SUBSTR('
-------------------------------------
08888888本回答被提问者采纳
相似回答