SQLite Tutorial SQLite Advanced SQLite Database SQLite References

SQLite CHAR() Function



The SQLite CHAR() function interprets each passed argument as an integer and returns a string consisting of the characters given by the code values of those integers.

Syntax

CHAR(X1, X2, ..., XN)

Parameters

X1, X2, ..., XN Required. Specify integers whose character values (according to the ASCII table) are to be retrieved.

Return Value

Returns a string consisting of the characters given by the code values of those integers.

Example 1:

The example below shows the usage of CHAR() function.

SELECT CHAR(72,69,76,76,79);
Result: 'HELLO'

SELECT CHAR('72',69,'76',76,79);
Result: 'HELLO'

SELECT CHAR('72.8',69,'76.3',76,79);
Result: 'HELLO'

SELECT CHAR(65,66,67);
Result: 'ABC'

Example 2:

Consider a database table called Sample with the following records:

Datax1x2x3
Data167117116
Data280117116
Data384111111
Data466111119
Data5677968
Data669110100

The statement given below can be used to get the string containing characters given by the code values specified by columns x1, x2 and x3.

SELECT *, CHAR(x1, x2, x3) AS CHAR_String FROM Sample;

The query will produce the following result:

Datax1x2x3CHAR_String
Data167117116Cut
Data280117116Put
Data384111111Too
Data466111119Bow
Data5677968COD
Data669110100End

❮ SQLite Functions