MySQL CHAR() Function

In MySQL, the CHAR() function converts each integer parameter to an character, and returns these characters as a string.

CHAR() Syntax

Here is the syntax of MySQL CHAR() function:

CHAR(num1, [num2, ...])

Parameters

num1, [num2, ...]
Required. They can be any type and will be converted to integers.

Return value

The CHAR() function returns a string consisting of the characters given by each integer argument.

The NULL value in the num1, [num2, ...] parameters will be ignored.

CHAR() Examples

Here are some examples of MySQL CHAR() function.

SELECT
    CHAR(65, 66, 67),
    CHAR(65, '66', '67'),
    CHAR(65.4, '66.5', '67.6'),
    CHAR(65, 66, NULL, 67)\G
          CHAR(65, 66, 67): ABC
      CHAR(65, '66', '67'): ABC
CHAR(65.4, '66.5', '67.6'): ABC
    CHAR(65, 66, NULL, 67): ABC

Here,for CHAR(65, 66, 67):

  1. The first parameter 65 is converted to A.
  2. The second parameter 66 is converted to B.
  3. The third parameter 67 is converted to C.
  4. Join A, B and C, and return ABC.