MySQL character data is case-sensitive. MySQL stores character type values, which are case-insensitive by default. Therefore, if the 'binary 'keyword is not specified during select, the default value returned is the size. 1 create table 'test _ t1' (2 'vr _ WEB_ACCOUNT 'varchar (100) DEFAULT NULL3) ENGINE = InnoDB default charset = utf8; 1 www.2cto.com insert into TEST_T1 VALUES ('mysql'), ('mysql'); 1 MySQL> select * from test_t1 where vr_web_account like'm % '; 2 + ---------------- + 3 | VR_WEB_ACCOUNT | 4 + ---------------- + 5 | MySQL | 6 | mysql | 7 + ---------------- + 82 rows in set (0.08 sec)
After the 'binary 'keyword is used in the query condition:
1 mysql> select * from test_t1 where binary vr_web_account like'm % '; 2 + ---------------- + 3 | VR_WEB_ACCOUNT | 4 + ------------------ + 5 | mysql | 6 + ---------------- + 71 row in set (0.00 sec)
The above is not the focus of this Note. This article mainly describes how to modify the character collation of column to ensure case sensitivity. I will not go into details about MySQL layer-4 character set control. Www.2cto.com 1 alter table 'test _ t1' modify column 'vr _ WEB_ACCOUNT 'varchar (100) character set utf8 COLLATE utf8_bin default null; 1 select * from test_t1 where vr_web_account like'm % '; 2 + ---------------- + 3 | VR_WEB_ACCOUNT | 4 + ------------------ + 5 | mysql | 6 + ---------------- + 71 row in set (0.00 sec) author Wang Zi's key