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

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

        如何在 MySQL 上进行 SQL 区分大小写的字符串比较

        时间:2023-08-18

            <tbody id='or0qP'></tbody>
        1. <legend id='or0qP'><style id='or0qP'><dir id='or0qP'><q id='or0qP'></q></dir></style></legend>

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

            <tfoot id='or0qP'></tfoot>

              <bdo id='or0qP'></bdo><ul id='or0qP'></ul>
                  <i id='or0qP'><tr id='or0qP'><dt id='or0qP'><q id='or0qP'><span id='or0qP'><b id='or0qP'><form id='or0qP'><ins id='or0qP'></ins><ul id='or0qP'></ul><sub id='or0qP'></sub></form><legend id='or0qP'></legend><bdo id='or0qP'><pre id='or0qP'><center id='or0qP'></center></pre></bdo></b><th id='or0qP'></th></span></q></dt></tr></i><div id='or0qP'><tfoot id='or0qP'></tfoot><dl id='or0qP'><fieldset id='or0qP'></fieldset></dl></div>
                • 本文介绍了如何在 MySQL 上进行 SQL 区分大小写的字符串比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个函数返回五个大小写混合的字符.如果我对该字符串进行查询,无论大小写,它都会返回该值.

                  如何使 MySQL 字符串查询区分大小写?

                  解决方案

                  http://dev.mysql.com/doc/refman/5.0/en/case-sensitive.html

                  <块引用>

                  默认的字符集和排序规则是 latin1 和 latin1_swedish_ci,所以默认情况下非二进制字符串比较是不区分大小写的.这意味着如果您使用 col_name LIKE 'a%' 进行搜索,您将获得所有以 A 或 a 开头的列值.要使此搜索区分大小写,请确保其中一个操作数具有区分大小写或二进制排序规则.例如,如果您要比较都具有 latin1 字符集的列和字符串,则可以使用 COLLATE 运算符使任一操作数具有 latin1_general_cs 或 latin1_bin 排序规则:

                  col_name COLLATE latin1_general_cs LIKE 'a%'col_name LIKE 'a%' COLLATE latin1_general_cscol_name COLLATE latin1_bin LIKE 'a%'col_name LIKE 'a%' COLLATE latin1_bin

                  <块引用>

                  如果您希望始终以区分大小写的方式处理列,请使用区分大小写或二进制排序规则声明它.

                  I have a function that returns five characters with mixed case. If I do a query on this string it will return the value regardless of case.

                  How can I make MySQL string queries case sensitive?

                  解决方案

                  http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

                  The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default. This means that if you search with col_name LIKE 'a%', you get all column values that start with A or a. To make this search case sensitive, make sure that one of the operands has a case sensitive or binary collation. For example, if you are comparing a column and a string that both have the latin1 character set, you can use the COLLATE operator to cause either operand to have the latin1_general_cs or latin1_bin collation:

                  col_name COLLATE latin1_general_cs LIKE 'a%'
                  col_name LIKE 'a%' COLLATE latin1_general_cs
                  col_name COLLATE latin1_bin LIKE 'a%'
                  col_name LIKE 'a%' COLLATE latin1_bin
                  

                  If you want a column always to be treated in case-sensitive fashion, declare it with a case sensitive or binary collation.

                  这篇关于如何在 MySQL 上进行 SQL 区分大小写的字符串比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Mysql 可以拆分列吗? 下一篇:如何在 MySQL 中进行递归 SELECT 查询?

                  相关文章

                  最新文章

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

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

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