Home >Database >Mysql Tutorial >How to Perform Case-Sensitive String Comparisons in MySQL?

How to Perform Case-Sensitive String Comparisons in MySQL?

Susan Sarandon
Susan SarandonOriginal
2025-01-21 07:16:10192browse

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!

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