Let us first create a −
mysql> create table DemoTable1620 -> ( -> Subject varchar(20) -> ); Query OK, 0 rows affected (0.42 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1620 values('mysql'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1620 values('MySql'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1620 values('mYSQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1620 values('MySQL'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable1620 values('MYSQL'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select −
mysql> select * from DemoTable1620;
This will produce the following output −
+---------+ | Subject | +---------+ | mysql | | MySql | | mYSQL | | MySQL | | MYSQL | +---------+ 5 rows in set (0.00 sec)
Following is the query to search for the exact string value in MySQL −
mysql> select * from DemoTable1620 where Subject collate utf8_bin = 'MySQL';
This will produce the following output −
+---------+ | Subject | +---------+ | MySQL | +---------+ 1 row in set (0.00 sec)