MySQL CHAR is one of the String Function, which is used to convert the series of user specified integer values (ASCII values) to a character string. In this article we will show you, How to use this string CHAR in MySQL with example.
MySQL CHAR Syntax
The basic syntax of the CHAR Function in MySQL is as shown below:
SELECT CHAR (N,...Expression) FROM [Source]
TIP: Please refer ASCII Table to check the ASCII values for each and every character.
MySQL CHAR Function Example 1
The CHAR Function in MySQL is used to convert the integer values into characters using the ASCII Table. The following query will show multiple ways to use this function.
SELECT CHAR(75); SELECT CHAR(77, 121, 83, 81, 76); SELECT CHAR(NULL); SELECT CHAR('105'); SELECT CHAR('A');
MySQL CHAR Example 2
If you pass the integer value (argument value) larger than 255 (maximum allowed char) then the CHAR Function will convert the number into multiple bytes. For example, CHAR(256) is equal to CHAR(1, 0). The following query will show you the same.
SELECT CHAR(256); SELECT HEX(CHAR(1, 0)), HEX(CHAR(256)); SELECT CHAR(1242);
Thank You for Visiting Our Blog