Syntax error How to conduct an Accent Sensitive search in MySQL?

How to conduct an Accent Sensitive search in MySQL?



To conduct an Accent sensitive search in MySQL, we can use collation with utf8_bin. Here is the syntax to conduct accent sensitive search −

yourColumName dataType collate utf8_bin;

Apply the above syntax to conduct accent sensitive search. First, let us create a table −

mysql> create table AccentSearchDemo
   -> (
   -> Id varchar(100) collate utf8_bin
   -> );
Query OK, 0 rows affected (0.51 sec)

Inserting three records into the table −

mysql> insert into AccentSearchDemo values('John123');
Query OK, 1 row affected (0.31 sec)
mysql> insert into AccentSearchDemo values('Smith123');
Query OK, 1 row affected (0.15 sec)
mysql> insert into AccentSearchDemo values('123John');
Query OK, 1 row affected (0.11 sec)

Now we can display all the records with the help of SELECT statement. The query is as follows −

mysql> select *from AccentSearchDemo;

Here is the output −

+----------+
| Id       |
+----------+
| John123  |
| Smith123 |
| 123John  |
+----------+
3 rows in set (0.00 sec)
Updated on: 2019-07-30T22:30:24+05:30

332 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements