Char_Length()Function AND ASCII() Function in MariaDB
1. CHAR_LENGTH() Function :
In MariaDB, the CHAR_LENGTH function used for calculation of the total character length of a string. In this function, a string will be passed as a parameter and it will return the length of that string.it will a numeric type.
Syntax :
CHAR_LENGTH(string)
Parameter : Required.
string : It will return the string length.
Example-1 :
SELECT CHAR_LENGTH('GEEKSFORGEEKS');
Output :
13
Example-2 :
SELECT CHAR_LENGTH(' ');
Output :
1
Example-3 :
SELECT CHAR_LENGTH('');
Output :
0
Example-4 :
SELECT CHAR_LENGTH(NULL);
Output :
NULL
2. ASCII() Function :
In MariaDB, the ASCII function is used for finding the ASCII value of the leftmost character in this string. In this function, a string will be passed as a parameter and it will return the ASCII value of the left-most character.
Syntax :
ASCII(single_character)
Parameter : Required.
single_character : If more than one character will be pass then it will ignore all characters except the first character.
Example-1 :
SELECT ASCII('GeeksForGeeks');
Output :
107
Example-2 :
SELECT ASCII('G');
Output :
107
Example-3 :
SELECT ASCII('g');
Output :
147
Example-4 :
SELECT ASCII('7');
Output :
55
Please Login to comment...