How can we produce a string, other than default binary string, in a given character set by MySQL CHAR() function?

MySQLMySQLi Database

We can use the keyword USING to produce a string, other than default binary string, in a given character set. Following result set will demonstrate it −

mysql> Select CHARSET(CHAR(85 USING utf8));
+------------------------------+
| CHARSET(CHAR(85 USING utf8)) |
+------------------------------+
| utf8                         |
+------------------------------+
1 row in set (0.00 sec)

The above result set shows that the returned binary string is utf8 because we write utf8 after the keyword USING.

mysql> Select CHARSET(CHAR(85 USING latin1));
+--------------------------------+
| CHARSET(CHAR(85 USING latin1)) |
+--------------------------------+
| latin1                         |
+--------------------------------+
1 row in set (0.00 sec)

The above result set shows that the returned binary string is latin1 because we write latin1 after the keyword USING.

raja
Published on 21-Feb-2018 08:30:09
Advertisements