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

    1. <small id='XWwUw'></small><noframes id='XWwUw'>

      • <bdo id='XWwUw'></bdo><ul id='XWwUw'></ul>
    2. <legend id='XWwUw'><style id='XWwUw'><dir id='XWwUw'><q id='XWwUw'></q></dir></style></legend>

      oracle -- 将oracle表中的多个逗号分隔值拆分为多行

      时间:2023-09-19
          <tbody id='CFpCg'></tbody>
      • <tfoot id='CFpCg'></tfoot>

          1. <legend id='CFpCg'><style id='CFpCg'><dir id='CFpCg'><q id='CFpCg'></q></dir></style></legend>

          2. <small id='CFpCg'></small><noframes id='CFpCg'>

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

                本文介绍了oracle -- 将oracle表中的多个逗号分隔值拆分为多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在使用 oracle 拆分查询时遇到问题.

                I Have a problem with oracle split query.

                在 oracle 查询中使用 connect by 和正则表达式将逗号分隔的数据拆分为多行时,我得到了更多重复行.例如,实际上我的表有 150 行,其中两行有逗号分隔的字符串,所以总的来说我只需要得到 155 行,但我得到了 2000 行.如果我使用 distinct 其工作正常,但我不希望查询结果中有重复的行.

                While splitting comma separated data into multiple rows using connect by and regular expression in oracle query I am getting more duplicate rows. for example actually my table having 150 rows in that one two rows having comma separated strings so overall i have to get only 155 rows but i am getting 2000 rows. If i use distinct its working fine but i dont want duplicate rows in query result.

                我尝试了以下查询,但是它在查询结果中生成了重复的行:

                I tried the following query however it's generating duplicate rows in query result:

                WITH CTE AS (SELECT 'a,b,c,d,e' temp,1 slno  FROM DUAL
                              UNION 
                              SELECT 'f,g',2 from dual
                              UNION 
                               SELECT 'h',3 FROM DUAL)
                
                SELECT TRIM(REGEXP_SUBSTR( TEMP, '[^,]+', 1, LEVEL)) ,SLNO FROM CTE 
                CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(temp, '[^,]+')) + 1
                

                编辑

                上述选择查询只能拆分单个逗号分隔的字符串,但是在具有多行的表上执行时会产生重复的行.如何限制重复行?

                The above select query is only able to split a single comma delimited string, however, it produces duplicate rows when executed on a table with multiple rows. How to restrict the duplicate rows?

                推荐答案

                最后我想出了这个答案

                WITH CTE AS (SELECT 'a,b,c,d,e' temp, 1 slno FROM DUAL
                              UNION
                              SELECT 'f,g' temp, 2 slno FROM DUAL
                              UNION
                              SELECT 'h' temp, 3 slno FROM DUAL)
                SELECT TRIM(REGEXP_SUBSTR(temp, '[^,]+', 1, level)), slno
                FROM CTE
                CONNECT BY level <= REGEXP_COUNT(temp, '[^,]+')
                    AND PRIOR slno = slno
                    AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
                

                这篇关于oracle -- 将oracle表中的多个逗号分隔值拆分为多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Oracle 的自动增量 下一篇:带有 IN 子句参数的 Oracle 存储过程

                相关文章

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

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

              • <tfoot id='br95u'></tfoot>

                    <bdo id='br95u'></bdo><ul id='br95u'></ul>
                  <legend id='br95u'><style id='br95u'><dir id='br95u'><q id='br95u'></q></dir></style></legend>