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 is as shown below:

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

MySQL CHAR Function Example

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

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

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

SELECT CHAR(256);

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

SELECT CHAR(1242);
CHAR Example 2