Home >Database >Mysql Tutorial >How Can I Achieve Case-Sensitive Comparisons in MySQL Collations?
Case Sensitivity in MySQL Collation
It is common knowledge that MySQL collations end with "_ci," indicating case-insensitive comparisons. However, there may be scenarios where users require case-sensitive collation.
Solution:
According to the MySQL Manual: http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html
SHOW COLLATION WHERE COLLATION LIKE "%_cs"
Additional Considerations for UTF-8:
Research indicates that there are no UTF-8 collations using "_cs" in MySQL. For UTF-8 fields with case sensitivity, it is recommended to use "utf8_bin."
Note:
"utf8_bin" can affect ORDER BY functionality. To mitigate this, use the following syntax:
ORDER BY column COLLATE utf8_general_ci
References:
The above is the detailed content of How Can I Achieve Case-Sensitive Comparisons in MySQL Collations?. For more information, please follow other related articles on the PHP Chinese website!