Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Convert the column to a case-sensitive collation in MySQL?
For this, you can use COLLATE. Following is the syntax −
select *from yourTableName where yourColumnName LIKE yourValue COLLATE utf8_bin;
Let us first create a table −
mysql> create table DemoTable ( LastName varchar(100) ); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Brown');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('BROWN');
Query OK, 1 row affected (0.29 sec)
mysql> insert into DemoTable values('brown');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('BRoWN');
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----------+ | LastName | +----------+ | Brown | | BROWN | | brown | | BRoWN | +----------+ 4 rows in set (0.00 sec)
Following is the query for COLLATE −
mysql> select *from DemoTable where LastName LIKE 'BROWN' COLLATE utf8_bin;
Output
+----------+ | LastName | +----------+ | BROWN | +----------+ 1 row in set (0.00 sec)
Advertisements
