MySQL: ASCII Function
This MySQL tutorial explains how to use the MySQL ASCII function with syntax and examples.
Description
The MySQL ASCII function returns the numeric value of the left-most character of a string.
Syntax
The syntax for the ASCII function in MySQL is:
ASCII( single_character )
Parameters or Arguments
- single_character
- The specified character to retrieve the NUMBER code for. If more than one character is entered, the ASCII function will return the value for the first character and ignore all of the characters after the first.
Applies To
The ASCII function can be used in the following versions of MySQL:
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23
Example
Let's look at some MySQL ASCII function examples and explore how to use the ASCII function in MySQL.
For example:
mysql> SELECT ASCII('t'); Result: 116 mysql> SELECT ASCII('techonthenet.com'); Result: 116 mysql> SELECT ASCII('T'); Result: 84 mysql> SELECT ASCII('T2'); Result: 84
Advertisements