MySQL CHAR() Functions – String Functions

MySQL CHAR() Functions: Syntax

CHAR ( N,… [USING charset_name])


MySQL CHAR() Functions: Description

CHAR() functions interpret each argument N as an integer and return a string consisting of the characters given by the code values of those integers.

Note : NULL values are skipped.

CHAR() arguments larger than 255 are converted into multiple result bytes. For example, CHAR(256) is equivalent to CHAR(1,0), and CHAR(256*256) is equivalent to CHAR(1,0,0):


MySQL CHAR() Functions: Parameter

[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|lef|lef|left”]
Name, Required /Optional, Value Type, Description
N , Required, Integer , The input string.
[/table]


MySQL CHAR() Functions: Output

[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
string , returns a string consisting of the characters given by the code values of input integers.
[/table]


MySQL CHAR() Functions: Example 1

mysql> SELECT CHAR(84,85,84,79,82);
+———————-+
| CHAR(84,85,84,79,82) |
+———————-+
| TUTOR |
+———————-+
1 row in set (0.00 sec)

mysql> SELECT CHAR(84,85,84,NULL,79,82); //NULL values are skipped.
+—————————+
| CHAR(84,85,84,NULL,79,82) |
+—————————+
| TUTOR |
+—————————+
1 row in set (0.02 sec)


Below is the mysql terminal screen for above code :


See all MySQL String functions MySQL 8 String Functions.


Related articles : CHARACTER_LENGTH(), LENGTH(), OCTET_LENGTH(), HEX(), CONCAT(), POSITION().


PHP Related articles : SUBSTR(), SUBSTR_COUNT(), SUBSTR_COMPARE(), PHP5 STRING FUNCTIONS(), SUBSTR_REPLACE().

You may also like...