Home >Database >Mysql Tutorial >How to Perform Case-Sensitive String Comparisons in MySQL?
Achieving Case-Sensitive String Comparisons in MySQL
MySQL's default string comparison behavior is case-insensitive. This means queries typically ignore character casing. However, for situations demanding precise, case-sensitive matching, the BINARY
keyword provides the solution.
Using BINARY
forces a binary comparison, making MySQL sensitive to the case of each character.
For instance, this query only returns rows where the column value exactly matches 'value', considering case:
<code class="language-sql">SELECT * FROM `table` WHERE BINARY `column` = 'value';</code>
This feature is crucial when exact string matches are essential, ensuring data integrity and accurate retrieval.
The above is the detailed content of How to Perform Case-Sensitive String Comparisons in MySQL?. For more information, please follow other related articles on the PHP Chinese website!