Substring between characters in Oracle 9i

前端 未结 1 1656
礼貌的吻别
礼貌的吻别 2021-01-24 07:48

In later versions I can use this regexp_substr:

SELECT 
    ID, 
    regexp_substr(ID, \'[^.]+\', 1, 2) DATA 1, 
    regexp_substr(ID, \'[^.]+\', 1,         


        
相关标签:
1条回答
  • 2021-01-24 08:36

    You don't need regular expressions - just use SUBSTR and INSTR:

    SELECT id,
           SUBSTR( id, dot1 + 1, dot2 - dot1 - 1) AS data1,
           SUBSTR( id, dot2 + 1, dot3 - dot2 - 1) AS data2
    FROM   (
      SELECT id,
             INSTR( id, '.', 1, 1 ) AS dot1,
             INSTR( id, '.', 1, 2 ) AS dot2,
             INSTR( id, '.', 1, 3 ) AS dot3
      FROM   employees
    );
    
    0 讨论(0)
提交回复
热议问题