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

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

        有没有“LIKE"的组合?和“IN"在 SQL 中?

        时间:2023-07-18
        <i id='9MzGp'><tr id='9MzGp'><dt id='9MzGp'><q id='9MzGp'><span id='9MzGp'><b id='9MzGp'><form id='9MzGp'><ins id='9MzGp'></ins><ul id='9MzGp'></ul><sub id='9MzGp'></sub></form><legend id='9MzGp'></legend><bdo id='9MzGp'><pre id='9MzGp'><center id='9MzGp'></center></pre></bdo></b><th id='9MzGp'></th></span></q></dt></tr></i><div id='9MzGp'><tfoot id='9MzGp'></tfoot><dl id='9MzGp'><fieldset id='9MzGp'></fieldset></dl></div>
          <tbody id='9MzGp'></tbody>

          <legend id='9MzGp'><style id='9MzGp'><dir id='9MzGp'><q id='9MzGp'></q></dir></style></legend>
            • <bdo id='9MzGp'></bdo><ul id='9MzGp'></ul>
              <tfoot id='9MzGp'></tfoot>
            • <small id='9MzGp'></small><noframes id='9MzGp'>

                  本文介绍了有没有“LIKE"的组合?和“IN"在 SQL 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 SQL 中,我(遗憾地)经常不得不使用LIKE"条件,因为数据库几乎违反了所有规范化规则.我现在无法改变这一点.但这与问题无关.

                  In SQL I (sadly) often have to use "LIKE" conditions due to databases that violate nearly every rule of normalization. I can't change that right now. But that's irrelevant to the question.

                  此外,我经常使用诸如 WHERE something in (1,1,2,3,5,8,13,21) 之类的条件来提高我的 SQL 语句的可读性和灵活性.

                  Further, I often use conditions like WHERE something in (1,1,2,3,5,8,13,21) for better readability and flexibility of my SQL statements.

                  有没有什么办法可以在不编写复杂的子选择的情况下将这两件事结合起来?

                  Is there any possible way to combine these two things without writing complicated sub-selects?

                  我想要像 WHERE something LIKE ('bla%', '%foo%', 'batz%') 一样简单的东西,而不是这样:

                  I want something as easy as WHERE something LIKE ('bla%', '%foo%', 'batz%') instead of this:

                  WHERE something LIKE 'bla%'
                  OR something LIKE '%foo%'
                  OR something LIKE 'batz%'
                  

                  我在这里使用 SQl Server 和 Oracle,但我很感兴趣,如果这在任何 RDBMS 中都可行.

                  I'm working with SQl Server and Oracle here but I'm interested if this is possible in any RDBMS at all.

                  推荐答案

                  LIKE & 没有组合SQL 中的 IN,更不用说 TSQL (SQL Server) 或 PLSQL (Oracle).部分原因是全文搜索 (FTS) 是推荐的替代方案.

                  There is no combination of LIKE & IN in SQL, much less in TSQL (SQL Server) or PLSQL (Oracle). Part of the reason for that is because Full Text Search (FTS) is the recommended alternative.

                  Oracle 和 SQL Server FTS 实现都支持 CONTAINS 关键字,但语法仍然略有不同:

                  Both Oracle and SQL Server FTS implementations support the CONTAINS keyword, but the syntax is still slightly different:

                  WHERE CONTAINS(t.something, 'bla OR foo OR batz', 1) > 0
                  

                  SQL 服务器:

                  WHERE CONTAINS(t.something, '"bla*" OR "foo*" OR "batz*"')
                  

                  您查询的列必须是全文索引.

                  The column you are querying must be full-text indexed.

                  参考:

                  • 使用 Oracle Text 构建全文搜索应用程序
                  • 了解 SQL Server Full-文本

                  这篇关于有没有“LIKE"的组合?和“IN"在 SQL 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:GROUP BY 与 MAX(DATE) 下一篇:ANSI JOIN 与非 ANSI JOIN 查询的性能会不同吗?

                  相关文章

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

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

                    <tfoot id='jRRaj'></tfoot>

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