• <bdo id='G677x'></bdo><ul id='G677x'></ul>
      <tfoot id='G677x'></tfoot>
    1. <small id='G677x'></small><noframes id='G677x'>

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

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

        MySQL 中不区分重音的搜索查询

        时间:2023-10-26
          <bdo id='5SIli'></bdo><ul id='5SIli'></ul>

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

                <tbody id='5SIli'></tbody>

              • <tfoot id='5SIli'></tfoot>
              • <legend id='5SIli'><style id='5SIli'><dir id='5SIli'><q id='5SIli'></q></dir></style></legend>

                <small id='5SIli'></small><noframes id='5SIli'>

                1. 本文介绍了MySQL 中不区分重音的搜索查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法让搜索查询重音不敏感?

                  Is there any way to make search query accent insensitive?

                  列和表的排序规则是 utf8_polish_ci,我不想更改它们.

                  the column's and table's collation are utf8_polish_ci and I don't want to change them.

                  示例词:toruń

                  select * from pages where title like '%torun%'
                  

                  它没有找到toruń".我该怎么做?

                  It doesn't find "toruń". How can I do that?

                  推荐答案

                  您可以在 sql 查询中在运行时更改排序规则,

                  You can change the collation at runtime in the sql query,

                  ...where title like '%torun%' collate utf8_general_ci
                  

                  但请注意,在运行时动态更改排序规则会放弃 mysql 使用索引的可能性,因此在大型表上的性能可能会很糟糕.

                  but beware that changing the collation on the fly at runtime forgoes the possibility of mysql using an index, so performance on large tables may be terrible.

                  或者,您可以将该列复制到另一列,例如 searchable_title,但更改其上的排序规则.做这种类型的事情实际上很常见,在这种情况下,您复制数据,但以稍微不同的形式保存数据,这些形式针对某些特定的工作负载/目的进行了优化.您可以使用触发器作为保持重复列同步的好方法.如果编入索引,此方法有可能表现良好.

                  Or, you can copy the column to another column, such as searchable_title, but change the collation on it. It's actually common to do this type of stuff, where you copy data but have it in some slightly different form that's optimized for some specific workload/purpose. You can use triggers as a nice way to keep the duplicated columns in sync. This method has the potential to perform well, if indexed.

                  注意 - 确保您的数据库确实具有这些字符而不是 html 实体.此外,您的连接的字符集也很重要.上面假设它被设置为 utf8,例如,通过 set names 像 <代码>设置名称utf8

                  Note - Make sure that your db really has those characters and not html entities. Also, the character set of your connection matters. The above assumes it's set to utf8, for example, via set names like set names utf8

                  如果没有,您需要一个介绍人来获取文字值>

                  If not, you need an introducer for the literal value

                  ...where title like _utf8'%torun%' collate utf8_general_ci
                  

                  当然,单引号中的值实际上必须是 utf8 编码的,即使 sql 查询的其余部分不是.

                  and of course, the value in the single quotes must actually be utf8 encoded, even if the rest of the sql query isn't.

                  这篇关于MySQL 中不区分重音的搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么一些mysql连接在删除+插入后选择mysql数据库中的旧数据? 下一篇:MySQL - 如何按相关性排序?INNODB 表

                  相关文章

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

                      <legend id='9WUmJ'><style id='9WUmJ'><dir id='9WUmJ'><q id='9WUmJ'></q></dir></style></legend>
                    1. <small id='9WUmJ'></small><noframes id='9WUmJ'>

                    2. <tfoot id='9WUmJ'></tfoot>