Home >Database >Mysql Tutorial >MySQL字符串比较大小写问题

MySQL字符串比较大小写问题

WBOY
WBOYOriginal
2016-06-07 16:37:381350browse

刚刚才知道MySQL的varchar类型比较默认是忽略大小写的,还忽略最后的空格。C.5.5.1. Case Sensitivity in String Searches mysql SELECT 'a' = 'A'; - 1 解决方案是使用BINARY操作符10.1.7.7. The BINARY Operator mysql SELECT BINARY 'a' = 'A'; - 0mysql

刚刚才知道MySQL的varchar类型比较默认是忽略大小写的,还忽略最后的空格。C.5.5.1. Case Sensitivity in String Searches

<code>mysql> SELECT 'a' = 'A';
    -> 1
</code>

解决方案是使用BINARY操作符10.1.7.7. The BINARY Operator

<code>mysql> SELECT BINARY 'a' = 'A';
        -> 0
mysql> SELECT 'a' = 'a ';
        -> 1
mysql> SELECT BINARY 'a' = 'a ';
        -> 0
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn