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

      <tfoot id='VwrzQ'></tfoot>

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

      在 Oracle IN 子句中使用 LIKE

      时间:2023-09-17
      <tfoot id='J9Pmt'></tfoot>

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

              <tbody id='J9Pmt'></tbody>

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

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

                本文介绍了在 Oracle IN 子句中使用 LIKE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我知道我可以编写一个查询,该查询将返回给定列中包含任意数量值的所有行,如下所示:

                I know I can write a query that will return all rows that contain any number of values in a given column, like so:

                Select * from tbl where my_col in (val1, val2, val3,... valn)
                

                但是,如果 val1 可以出现在 my_col 中的任何位置,它的数据类型为 varchar(300),我可能会改为:

                but if val1, for example, can appear anywhere in my_col, which has datatype varchar(300), I might instead write:

                select * from tbl where my_col LIKE '%val1%'
                

                有没有办法将这两种技术结合起来.我需要搜索大约 30 个可能的值,这些值可能出现在列的自由格式文本中的任何位置.

                Is there a way of combing these two techniques. I need to search for some 30 possible values that may appear anywhere in the free-form text of the column.

                以下列方式组合这两个语句似乎行不通:

                Combining these two statements in the following ways does not seem to work:

                select * from tbl where my_col LIKE ('%val1%', '%val2%', 'val3%',....) 
                
                select * from tbl where my_col in ('%val1%', '%val2%', 'val3%',....)
                

                推荐答案

                这里有用的是 PostgreSQL 中可用的 LIKE ANY 谓词

                What would be useful here would be a LIKE ANY predicate as is available in PostgreSQL

                SELECT * 
                FROM tbl
                WHERE my_col LIKE ANY (ARRAY['%val1%', '%val2%', '%val3%', ...])
                

                不幸的是,该语法在 Oracle 中不可用.您可以使用 OR 扩展量化比较谓词,但是:

                Unfortunately, that syntax is not available in Oracle. You can expand the quantified comparison predicate using OR, however:

                SELECT * 
                FROM tbl
                WHERE my_col LIKE '%val1%' OR my_col LIKE '%val2%' OR my_col LIKE '%val3%', ...
                

                或者,使用 EXISTS 谓词和 辅助数组数据结构创建半连接(请参阅此详情的问题):

                Or alternatively, create a semi join using an EXISTS predicate and an auxiliary array data structure (see this question for details):

                SELECT *
                FROM tbl t
                WHERE EXISTS (
                  SELECT 1
                  -- Alternatively, store those values in a temp table:
                  FROM TABLE (sys.ora_mining_varchar2_nt('%val1%', '%val2%', '%val3%'/*, ...*/))
                  WHERE t.my_col LIKE column_value
                )
                

                对于真正的全文搜索,您可能需要查看 Oracle Text:http://www.oracle.com/technetwork/database/enterprise-edition/index-098492.html

                For true full-text search, you might want to look at Oracle Text: http://www.oracle.com/technetwork/database/enterprise-edition/index-098492.html

                这篇关于在 Oracle IN 子句中使用 LIKE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:ORACLE IIF 声明 下一篇:MySQL 相当于 Oracle 的 SEQUENCE.NEXTVAL

                相关文章

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

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