MySQL ASCII() Function

The ASCII() function returns the ASCII code of the first character in a given string or character value. If the input string contains more than one character, only the first character is evaluated.

Tutorials dojo strip

MySQL ASCII Function Syntax

SQL

MySQL ASCII Function Example

This query returns the ASCII value of the first character in the first_name column from the Patients table.

SQL

Note: The ASCII() function is supported in MySQL but not in SQLite. This example does not work in the TechKubo playground.

MySQL ASCII Function Parameter

ParameterDescription
characterThe input string or character. Only the first character is evaluated.

MySQL ASCII Function Notes:

  • If multiple characters are provided, only the first is used.
  • If the input is NULL, the result is NULL.
  • Supported starting with MySQL 4.0.

Tutorials dojo strip