MariaDB CHR() Function

In MariaDB, CHR() is a built-in string function, which converts the specified integer parameter into the corresponding character and returns it.

Unlike CHAR(), CHAR() can accept multiple parameters, and the character set to use can be specified via the USING clause.

MariaDB CHR() Syntax

Here is the syntax of the MariaDB CHR() function:

CHR(num)

Parameters

num

Required. An integer, or a value convertible to an integer.

If you pass in more than one parameter, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'CHR'.

Return value

The MariaDB CHR() function returns characters corresponding to integer arguments.

If you provide a NULL value, the CHR() function will return NULL.

MariaDB CHAR() Examples

The following statement uses the MariaDB CHR() function to return the corresponding character of 65:

SELECT CHR(65);

Output:

+---------+
| CHR(65) |
+---------+
| A       |
+---------+

The calculation process for CHR() and ASCII() is reversed, as shown in the following example:

SELECT CHR(65), ASCII(CHR(65));

Output:

+---------+----------------+
| CHR(65) | ASCII(CHR(65)) |
+---------+----------------+
| A       |             65 |
+---------+----------------+

Conclusion

In MariaDB, CHR() is a built-in string function, which converts the specified integer parameter into the corresponding character and returns it.