• <bdo id='n2uh8'></bdo><ul id='n2uh8'></ul>
      <i id='n2uh8'><tr id='n2uh8'><dt id='n2uh8'><q id='n2uh8'><span id='n2uh8'><b id='n2uh8'><form id='n2uh8'><ins id='n2uh8'></ins><ul id='n2uh8'></ul><sub id='n2uh8'></sub></form><legend id='n2uh8'></legend><bdo id='n2uh8'><pre id='n2uh8'><center id='n2uh8'></center></pre></bdo></b><th id='n2uh8'></th></span></q></dt></tr></i><div id='n2uh8'><tfoot id='n2uh8'></tfoot><dl id='n2uh8'><fieldset id='n2uh8'></fieldset></dl></div>

      <small id='n2uh8'></small><noframes id='n2uh8'>

        <legend id='n2uh8'><style id='n2uh8'><dir id='n2uh8'><q id='n2uh8'></q></dir></style></legend>

        <tfoot id='n2uh8'></tfoot>

      1. 使用 oracle SQL 按分隔符位置拆分字符串

        Split String by delimiter position using oracle SQL(使用 oracle SQL 按分隔符位置拆分字符串)

              <small id='x7hKL'></small><noframes id='x7hKL'>

              <i id='x7hKL'><tr id='x7hKL'><dt id='x7hKL'><q id='x7hKL'><span id='x7hKL'><b id='x7hKL'><form id='x7hKL'><ins id='x7hKL'></ins><ul id='x7hKL'></ul><sub id='x7hKL'></sub></form><legend id='x7hKL'></legend><bdo id='x7hKL'><pre id='x7hKL'><center id='x7hKL'></center></pre></bdo></b><th id='x7hKL'></th></span></q></dt></tr></i><div id='x7hKL'><tfoot id='x7hKL'></tfoot><dl id='x7hKL'><fieldset id='x7hKL'></fieldset></dl></div>
              <legend id='x7hKL'><style id='x7hKL'><dir id='x7hKL'><q id='x7hKL'></q></dir></style></legend>
            • <tfoot id='x7hKL'></tfoot>

              • <bdo id='x7hKL'></bdo><ul id='x7hKL'></ul>

                    <tbody id='x7hKL'></tbody>
                  本文介绍了使用 oracle SQL 按分隔符位置拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个字符串,我想在某个位置用定界符分割该字符串.

                  I have a string and I would like to split that string by delimiter at a certain position.

                  例如,我的字符串是 F/P/O 而我要查找的结果是:

                  For example, my String is F/P/O and the result I am looking for is:

                  因此,我想用最远的分隔符分隔字符串.
                  注意:我的一些字符串是 F/O 也适用于我下面的 SQL 工作正常并返回所需的结果.

                  Therefore, I would like to separate the string by the furthest delimiter.
                  Note: some of my strings are F/O also for which my SQL below works fine and returns desired result.

                  我写的SQL如下:

                  SELECT Substr('F/P/O', 1, Instr('F/P/O', '/') - 1) part1, 
                         Substr('F/P/O', Instr('F/P/O', '/') + 1)    part2 
                  FROM   dual
                  

                  结果是:

                  为什么会发生这种情况,我该如何解决?

                  Why is this happening and how can I fix it?

                  推荐答案

                  您想为此使用 regexp_substr().这应该适用于您的示例:

                  You want to use regexp_substr() for this. This should work for your example:

                  select regexp_substr(val, '[^/]+/[^/]+', 1, 1) as part1,
                         regexp_substr(val, '[^/]+$', 1, 1) as part2
                  from (select 'F/P/O' as val from dual) t
                  

                  这里顺便说一下,是 SQL Fiddle.

                  Here, by the way, is the SQL Fiddle.

                  糟糕.我错过了问题的一部分,它说 last 分隔符.为此,我们可以在第一部分使用 regex_replace():

                  Oops. I missed the part of the question where it says the last delimiter. For that, we can use regex_replace() for the first part:

                  select regexp_replace(val, '/[^/]+$', '', 1, 1) as part1,
                         regexp_substr(val, '[^/]+$', 1, 1) as part2
                  from (select 'F/P/O' as val from dual) t
                  

                  还有这里是对应的 SQL Fiddle.

                  And here is this corresponding SQL Fiddle.

                  这篇关于使用 oracle SQL 按分隔符位置拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                    <i id='GmI9C'><tr id='GmI9C'><dt id='GmI9C'><q id='GmI9C'><span id='GmI9C'><b id='GmI9C'><form id='GmI9C'><ins id='GmI9C'></ins><ul id='GmI9C'></ul><sub id='GmI9C'></sub></form><legend id='GmI9C'></legend><bdo id='GmI9C'><pre id='GmI9C'><center id='GmI9C'></center></pre></bdo></b><th id='GmI9C'></th></span></q></dt></tr></i><div id='GmI9C'><tfoot id='GmI9C'></tfoot><dl id='GmI9C'><fieldset id='GmI9C'></fieldset></dl></div>
                  1. <legend id='GmI9C'><style id='GmI9C'><dir id='GmI9C'><q id='GmI9C'></q></dir></style></legend>

                    <small id='GmI9C'></small><noframes id='GmI9C'>

                    <tfoot id='GmI9C'></tfoot>

                        • <bdo id='GmI9C'></bdo><ul id='GmI9C'></ul>

                              <tbody id='GmI9C'></tbody>