• <legend id='X3cfB'><style id='X3cfB'><dir id='X3cfB'><q id='X3cfB'></q></dir></style></legend>

      <tfoot id='X3cfB'></tfoot>

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

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

        MySQL - 如何使用 LIKE 搜索精确的单词匹配?

        时间:2023-06-02

          <tbody id='xsQKc'></tbody>

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

                <bdo id='xsQKc'></bdo><ul id='xsQKc'></ul>

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

                  本文介绍了MySQL - 如何使用 LIKE 搜索精确的单词匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用此查询来选择数据:

                  I'm using this query to select data:

                  mysql_query("SELECT * FROM products WHERE product_name LIKE '%".$search."%'");
                  

                  唯一的问题是,它有时会选择比我想要的更多的东西.

                  The only problem is, that it sometimes selects more, than I would like.

                  例如,我想选择产品BLA",但我的查询也选择产品BLABLA".明确地说,如果我想选择产品 1",我不希望查询选择产品 11".

                  For example, I would like to select product "BLA", but my query select product "BLABLA" as well. To be clear, if i wanted to select "Product 1", I don't want the query to select "Product 11".

                  有人知道如何管理吗?

                  谢谢.

                  推荐答案

                  您只想搜索单词边界吗?如果是这样,一个粗略的版本可能是:

                  Do you just want to search on word boundaries? If so a crude version might be:

                  SELECT * FROM products WHERE product_name LIKE "% foo %";
                  

                  或者你可以更聪明一点,用下面的REGEXP

                  Or you could be a bit cleverer and look for word boundaries with the following REGEXP

                  SELECT * FROM products WHERE product_name RLIKE "[[:<:]]foo[[:>:]]";
                  

                  这篇关于MySQL - 如何使用 LIKE 搜索精确的单词匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SQLite 和自定义顺序 下一篇:MySQL 从一个数据库插入另一个数据库

                  相关文章

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

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

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

                        <bdo id='YIuQX'></bdo><ul id='YIuQX'></ul>

                    1. <tfoot id='YIuQX'></tfoot>