Home >Database >Mysql Tutorial >How can we generate a string other than the default binary string in a given character set via the MySQL CHAR() function?

How can we generate a string other than the default binary string in a given character set via the MySQL CHAR() function?

WBOY
WBOYforward
2023-09-06 10:17:021229browse

我们如何通过 MySQL CHAR() 函数在给定的字符集中生成除默认二进制字符串之外的字符串?

We can use the keyword USING to generate a string in a given character set instead of the default binary string. The 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 wrote 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 wrote latin1 after the keyword USING.

The above is the detailed content of How can we generate a string other than the default binary string in a given character set via the MySQL CHAR() function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete