sql

1.截取字符串

mysql

SUBSTRING_INDEX(SUBSTRING_INDEX(b.`ELEMENT_ALLPARENT_ID`,',',3),',',-1) AS deno

oracle

'402881e96274cd86016274cd86630000,8aaa87176415997a016421903b720034,402881e96275cee9016275d4fbdd000a'   截取,号后的32位

select substr('402881e96274cd86016274cd86630000,8aaa87176415997a016421903b720034,402881e96275cee9016275d4fbdd000a',
instr('402881e96274cd86016274cd86630000,8aaa87176415997a016421903b720034,402881e96275cee9016275d4fbdd000a',',',-1,1)+1,32
)from dual

instr(sourceString,destString,start,appearPosition).   instr('源字符串' , '目标字符串' ,'开始位置','第几次出现'
返回目标字符串的位置   下标从1开始
SQL> select instr('yuechaotianyuechao','ao') position from dual;
 
 POSITION
 ----------
 6
 
从第7个字符开始搜索<br>
SQL> select instr('yuechaotianyuechao','ao', 7) position from dual;
 
 POSITION
 ----------
 17
 
substr( string, start_position, [ length ] )       substr('目标字符串',开始位置,长度)
      substr('This is a test', 6, 2)     would return 'is'
      substr('This is a test', 6)     would return 'is a test'
      substr('TechOnTheNet', -3, 3)     would return 'Net'
原文地址:https://www.cnblogs.com/jentary/p/11579137.html