
- 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 to make SQL case sensitive string comparison in MySQL?
Firstly, we will create a table with the help of CREATE command.
Creating a table −
mysql> CREATE table InCaseSensDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)
Inserting records into the table with the help of INSERT command −
mysql> INSERT into InCaseSensDemo values('JOhN'); Query OK, 1 row affected (0.11 sec) mysql> INSERT into InCaseSensDemo values('bob'); Query OK, 1 row affected (0.21 sec) mysql> INSERT into InCaseSensDemo values('BoB'); Query OK, 1 row affected (0.13 sec) mysql> INSERT into InCaseSensDemo values('Bob'); Query OK, 1 row affected (0.18 sec)
Displaying all the records with the help of SELECT command −
mysql> SELECT * from InCaseSensDemo;
The following is the output −
+------+ | Name | +------+ | JOhN | | bob | | BoB | | Bob | +------+ 4 rows in set (0.00 sec)
Here is the syntax TO make comparison of case sensitive string −
SELECT * FROM yourTableName WHERE BINARY column_name = 'value';
Applying the above syntax to compare the case sensitive value −
mysql> SELECT * FROM InCaseSensDemo WHERE BINARY Name = 'bob';
The following is the output
+------+ | Name | +------+ | bob | +------+ 1 row in set (0.00 sec)
- Related Articles
- How MySQL can perform case-sensitive string comparison?
- Case sensitive string comparison in Java.
- How to do case-sensitive string comparison in JavaScript?
- What kind of string comparison, case-sensitive or not, can be performed by MySQL?
- How do I make my string comparison case insensitive?
- How do we make my string comparison case insensitive in java?
- How to achieve case sensitive uniqueness and case insensitive search in MySQL?
- Case-insensitive string comparison in C++
- How do you force MySQL LIKE to be case sensitive?
- How to do case insensitive string comparison of strings in JavaScript
- Convert the column to a case-sensitive collation in MySQL?
- Are MySQL database and table names case-sensitive?
- How do I do a case insensitive string comparison in Python?
- How to use comparison operator for numeric string in MySQL?
- Case-sensitive sort in JavaScript

Advertisements