Query MySQL with unicode char code?


Let us first create a table −

mysql> create table DemoTable
   -> (
   -> Value int
   -> );
Query OK, 0 rows affected (0.57 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable values(0x41);
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable values(0x30);
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values(0x61);
Query OK, 1 row affected (0.27 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable;

Output

This will produce the following output −

+-------+
| Value |
+-------+
|    65 |
|    48 |
|    97 |
+-------+
3 rows in set (0.00 sec)

Following is the query to work with unicode char code −

mysql> select char(Value) from DemoTable;

Output

This will produce the following output −

+-------------+
| char(Value) |
+-------------+
| A           |
| 0           |
| a           |
+-------------+
3 rows in set (0.00 sec)

Updated on: 30-Jun-2020

296 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements