MySQL CHAR Function

MySQL CHAR is one of the String Functions, which helps convert the series of user-specified integer values (ASCII values) to a character string. The basic syntax of the CHAR Function in MySQL is as shown below:

SELECT CHAR (N,...Expression)
FROM [Source]

MySQL CHAR Function Example 1

The String CHAR in MySQL converts the integer values into characters using the ASCII Table. The following string CHAR query shows multiple ways to use this function by passing different values.

TIP: Please refer ASCII Table to check the ASCII values for each and every character in MySQL.

SELECT CHAR(75);

SELECT CHAR(77, 121, 83, 81, 76);

SELECT CHAR(NULL);

SELECT CHAR('105');

SELECT CHAR('A');
MySQL CHAR Function Example 1

String CHAR Example 2

If you pass the integer value (argument value) larger than 255 (maximum allowed char), then the MySQL CHAR converts the number into multiple bytes. For example, CHAR(256) is equal to CHAR(1, 0). The following CHAR String Function query shows you the same with different values.

SELECT CHAR(256);

SELECT HEX(CHAR(1, 0)), HEX(CHAR(256));

SELECT CHAR(1242);
MySQL CHAR Function Example 2