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

MySQL字符串比较大小写问题

WBOY
Release: 2016-06-07 16:37:38
Original
1349 people have browsed it

刚刚才知道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>
Copy after login

解决方案是使用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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template