Mysql Ascii Function

MySQL: ASCII Function

This tutorial explains how to use the MySQL ASCII function with syntax and examples.


The MySQL ASCII function returns the numeric value of the left-most character of a string.


The syntax for the ASCII function in MySQL is:

ASCII( single_character )

Parameters or Arguments


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


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');
Output: 116

mysql> SELECT ASCII('');
Output: 65

mysql> SELECT ASCII('T');
Output: 84

mysql> SELECT ASCII('T2');
Output: 84