MySQL ASCII is an inbuilt function in MySQL. It returns the ASCII value of the first character of the input string to it. In this article, we will discuss the MySQL ASCII Function. Also, we will discuss a few examples of using it.
Syntax
ASCII (string)
Parameters
The MySQL ASCII Function expects only one parameter. A string is input to the function.
Return Value
The function returns the integer ASCII value of the first character of the string input to it. However, if the string is empty, the function returns 0.

Examples
Let’s discuss a few examples of using the function.
Example 1: Single Characters
For instance, consider single characters as input.
mysql> SELECT ASCII('a') as lowercase, ASCII('A') as uppercase; +-----------+-----------+ | lowercase | uppercase | +-----------+-----------+ | 97 | 65 | +-----------+-----------+
In the above example, the function returns the ASCII values of ‘a’ and ‘A’ respectively.
Example 2: Input String
Similarly, for a string input, the function returns the ASCII value of the first character of the string.
mysql> SELECT ASCII('Concatly') as asciivalue; +------------+ | asciivalue | +------------+ | 67 | +------------+
In the above example, the function returns the ASCII value of ‘C’.
Example 3: Empty String
However, if the input string is empty, the function returns 0.
mysql> SELECT ASCII('') as asciivalue; +------------+ | asciivalue | +------------+ | 0 | +------------+
Conclusion
In conclusion, we discussed the MySQL ASCII Function in this article. You can read more about it on the Official MySQL Documentation. Additionally, you can learn about more MySQL String Functions on Concatly.

Vishesh is currently working as an Intermediate Software Engineer with Orion Health, New Zealand. He graduated with a Masters in Information Technology from the University of Auckland in 2021. With more than 4 years of work experience, his expertise includes Java, Python, Machine Learning, PHP, Databases, Design and Architecture.