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') positionfrom dual;
POSITION
----------
6
从第7个字符开始搜索
SQL>select instr('yuechaotianyuechao','ao', 7) positionfrom dual;
POSITION
----------
17
substr(string, start_position, [ length ] ) substr('目标字符串',开始位置,长度)
substr('This is a test', 6, 2) wouldreturn 'is'
substr('This is a test', 6) wouldreturn 'is a test'
substr('TechOnTheNet', -3, 3) wouldreturn 'Net'