Name

ASCII( )

Synopsis

ASCII(string)

This function returns the ASCII code for the first character of a given string. If you’re entering raw text, you must enclose string within quotes. If the argument is a column, do not enclose it in quotes. If string is empty, 0 is returned.

SELECT ASCII('A') AS A, ASCII(name_last) AS Professor
FROM teachers WHERE name_last = 'McAllister';
+----+-----------+
| A  | Professor |
+----+-----------+
| 65 |        77 |
+----+-----------+

Only the M in the professor’s name is converted to its ASCII equivalent. It displays the ASCII value for A and the first letter of the name.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.