Name

ORD()

Synopsis

ORD(string)

This function returns an ordinal value, the position of a character in the ASCII character set of the leftmost character in a given string. For multibyte characters, it follows a formula to determine the results: byte1 + (byte2 * 256) + (byte3 *2562)....

Here is an example:

SELECT ORD('A'), ORD('a');

+----------+----------+
| ORD('A') | ORD('a') |
+----------+----------+
|       65 |       97 |
+----------+----------+

Get MySQL in a Nutshell, 2nd Edition 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.