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?
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!