<bdo id='FwlmF'></bdo><ul id='FwlmF'></ul>
  • <small id='FwlmF'></small><noframes id='FwlmF'>

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

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

        使用“IN"Oracle SQL 中 replace() 函数输出中带有逗号分隔字符串的子句

        时间:2023-09-20
      3. <small id='xREO0'></small><noframes id='xREO0'>

              <tbody id='xREO0'></tbody>

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

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

                  本文介绍了使用“IN"Oracle SQL 中 replace() 函数输出中带有逗号分隔字符串的子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个逗号分隔的字符串,我想在语句的IN"子句中使用它.例如:100,101,102

                  I have an comma delimited string which I want to use in an "IN" clause of the statement. eg: 100,101,102

                  由于 In 和 "IN" 子句我必须引用单个字符串,所以我使用了替换函数:例如:select ''''||replace('100,101,102',',',''', ''')||'''' from dual;

                  Since In and "IN" clause I have to quote the individial strings, I use a replace function: eg: select ''''||replace('100,101,102',',',''', ''')||'''' from dual;

                  上述查询有效,但是,当我尝试将上述查询的输出用作IN"子句的输入时,它不返回任何数据.我只受 SQL 语句的限制,所以我不能使用 PL/SQL 代码.请帮忙.

                  The above query works, however, when I try to use the output of the above as an input to the "IN" clause, it returns no data. I am restricted by only SQL statements, so I cannot use PL/SQL code. Kindly help.

                  select * from employee where employee_number in (
                      select ''''||replace('100,101,102',',',''', ''')||'''' from dual);
                  

                  以上方法无效.请让我知道我缺少什么.

                  The above does not work. Please let me know what I am missing.

                  推荐答案

                  这种情况下的一般方法是将逗号分隔的列表解析为 Oracle 集合,并在 SQL 语句中使用该集合.Tom Kyte 在他关于 变量 IN 列表.

                  The general approach in this case would be to parse the comma-separated list into an Oracle collection and to use that collection in your SQL statement. Tom Kyte has an example of this in his discussion on variable IN lists.

                  假设您从该线程创建 myTableType 类型和 in_list 函数,您应该能够做到

                  Assuming you create the myTableType type and the in_list function from that thread, you should be able to do

                  SELECT *
                    FROM employee
                   WHERE employee_number IN (
                      SELECT *
                        FROM TABLE( in_list( p_your_comma_separated_list ) )
                      )
                  

                  这篇关于使用“IN"Oracle SQL 中 replace() 函数输出中带有逗号分隔字符串的子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么使用 JOIN 子句而不是 WHERE 条件? 下一篇:使用 to_char 格式化间隔

                  相关文章

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

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

                    <legend id='yqBT5'><style id='yqBT5'><dir id='yqBT5'><q id='yqBT5'></q></dir></style></legend>
                      <tfoot id='yqBT5'></tfoot>