
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How MySQL can perform case-sensitive string comparison?
As we know that MySQL is not case-sensitive while comparing characters but it can be changed i.e. MySQL can perform case-sensitive string comparison if we will use BINARY keyword before the expression. Actually, BINARY keyword instructs MySQL to compare the characters in the string using their underlying ASCII values rather than just their letters. It can be illustrated with the following example from table ‘Employee’ having the following data −
mysql> Select * from Employee; +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 2 | Rahul | 20000 | | 3 | Advik | 25000 | | 4 | Aarav | 65000 | | 5 | Ram | 20000 | | 6 | Mohan | 30000 | | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+--------+--------+ 8 rows in set (0.09 sec)
The query below will use BINARY keyword to force MySQL for performing case-sensitive string comparison.
mysql> Select * from Employee WHERE BINARY Name IN ('Gaurav','RAM'); +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | +----+--------+--------+ 1 row in set (0.00 sec)
- Related Articles
- How to make SQL case sensitive string comparison in MySQL?
- Case sensitive string comparison in Java.
- What kind of string comparison, case-sensitive or not, can be performed by MySQL?
- How to do case-sensitive string comparison in JavaScript?
- How to perform string comparison in TypeScript?
- How to achieve case sensitive uniqueness and case insensitive search in MySQL?
- Case-insensitive string comparison in C++
- How do I make my string comparison case insensitive?
- How do you force MySQL LIKE to be case sensitive?
- Are MySQL database and table names case-sensitive?
- How do we make my string comparison case insensitive in java?
- How do I do a case insensitive string comparison in Python?
- How to do case insensitive string comparison of strings in JavaScript
- Is Python case-sensitive or case-insensitive?
- Convert the column to a case-sensitive collation in MySQL?

Advertisements