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

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

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

        如何在 SQL 中将 varchar 列拆分为多个值?

        How to split a varchar column as multiple values in SQL?(如何在 SQL 中将 varchar 列拆分为多个值?)
        • <bdo id='qDc7J'></bdo><ul id='qDc7J'></ul>
        • <i id='qDc7J'><tr id='qDc7J'><dt id='qDc7J'><q id='qDc7J'><span id='qDc7J'><b id='qDc7J'><form id='qDc7J'><ins id='qDc7J'></ins><ul id='qDc7J'></ul><sub id='qDc7J'></sub></form><legend id='qDc7J'></legend><bdo id='qDc7J'><pre id='qDc7J'><center id='qDc7J'></center></pre></bdo></b><th id='qDc7J'></th></span></q></dt></tr></i><div id='qDc7J'><tfoot id='qDc7J'></tfoot><dl id='qDc7J'><fieldset id='qDc7J'></fieldset></dl></div>

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

              <legend id='qDc7J'><style id='qDc7J'><dir id='qDc7J'><q id='qDc7J'></q></dir></style></legend>
                  <tbody id='qDc7J'></tbody>
                <tfoot id='qDc7J'></tfoot>

                • 本文介绍了如何在 SQL 中将 varchar 列拆分为多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个 SQL Select 语句

                  SELECTAD_Ref_List.ValueFROM AD_Ref_ListWHERE AD_Ref_List.AD_Reference_ID= 1000448

                  这是SELECT的结果:

                  为了限制选定的行,我在其他表中存储了几个值,如下所示:

                  SELECT xx_insert.XX_DocAction_Next从 xx_insert哪里 xx_insert_id = 1000283

                  所以,我最后的 SQL Select 是这样的:

                  SELECTAD_Ref_List.ValueFROM AD_Ref_ListWHERE AD_Ref_List.AD_Reference_ID= 1000448AND AD_Ref_List.Value IN(选择 xx_insert.XX_DocAction_Next从 xx_insert哪里 xx_insert_id = 1000283);

                  问题:这个 SELECT 没有返回任何行,因为 Oracle 已经转换成这样:AD_Ref_List.Value IN ('CO,VO')

                  但是,我需要的是:AD_Ref_List.Value IN ('CO','VO')

                  我该怎么做???

                  最好的问候

                  解决方案

                  将你在分隔列表中使用的分隔符中的值包裹起来,然后检查它是否是分隔列表的子字符串(也包括分隔符包裹围绕它):

                  SELECT r.ValueFROM AD_Ref_List r内连接 xx_insert xON ( ',' || x.XX_DocAction_Next || ',' LIKE '%,' || r.value || ',%' )WHERE r.AD_Reference_ID = 1000448AND x.xx_insert_id = 1000283;

                  <块引用>

                  我必须在 whereClause 中保留逻辑

                  真的,不要.上面的查询会更有效率.

                  但如果你必须这样做:

                  SELECT 值FROM AD_Ref_ListWHERE AD_Reference_ID = 1000448与值输入 (SELECT REGEXP_SUBSTR( XX_DocAction_Next, '[^,]+', 1, LEVEL )从 xx_insert哪里 xx_insert_id = 1000283按级别连接 <= REGEXP_COUNT( XX_DocAction_Next, '[^,]+' ));

                  I have this SQL Select Statement

                  SELECT 
                    AD_Ref_List.Value
                  FROM AD_Ref_List
                  WHERE AD_Ref_List.AD_Reference_ID= 1000448
                  

                  This is the result of SELECT:

                  To limit the selected rows, I have a couple of values stored in other table like this:

                  SELECT xx_insert.XX_DocAction_Next
                    FROM xx_insert
                    WHERE xx_insert_id = 1000283
                  

                  So, My final SQL Select is this:

                  SELECT 
                    AD_Ref_List.Value
                  FROM AD_Ref_List
                  WHERE AD_Ref_List.AD_Reference_ID= 1000448
                  AND AD_Ref_List.Value           IN
                    (SELECT xx_insert.XX_DocAction_Next
                    FROM xx_insert
                    WHERE xx_insert_id = 1000283
                    )
                  ;
                  

                  PROBLEM : This SELECT return no line, because Oracle has transformed like this: AD_Ref_List.Value IN ('CO,VO')

                  But, what I need is : AD_Ref_List.Value IN ('CO','VO')

                  How can I do this???

                  Best regards

                  解决方案

                  Wrap the value in the delimiter you are using in the delimited list and then check if it is a sub-string of the delimited list (also with the delimiters wrapped around it):

                  SELECT r.Value
                  FROM   AD_Ref_List r
                         INNER JOIN xx_insert x
                         ON ( ',' || x.XX_DocAction_Next || ',' LIKE '%,' || r.value || ',%' )
                  WHERE  r.AD_Reference_ID = 1000448
                  AND    x.xx_insert_id    = 1000283;
                  

                  i must keep the logic in the whereClause

                  Really, don't. The above query will be much more efficient.

                  But if you have to then:

                  SELECT Value
                  FROM   AD_Ref_List
                  WHERE  AD_Reference_ID = 1000448
                  AND    value IN (
                    SELECT REGEXP_SUBSTR( XX_DocAction_Next, '[^,]+', 1, LEVEL )
                    FROM   xx_insert
                    WHERE  xx_insert_id    = 1000283
                    CONNECT BY LEVEL <= REGEXP_COUNT( XX_DocAction_Next, '[^,]+' )
                  );
                  

                  这篇关于如何在 SQL 中将 varchar 列拆分为多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  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 查询中包含缺失的月份)
                  <tfoot id='ZM4wy'></tfoot>
                • <small id='ZM4wy'></small><noframes id='ZM4wy'>

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