MySQL ORD() function
ORD() function
MySQL ORD() returns the code for the leftmost character if that character is a multi-byte (sequence of one or more bytes) one. If the leftmost character is not a multi-byte character, ORD() returns the same value as the ASCII() function.
The formula to calculate the numeric values of its constituent bytes is :
(1st byte code) + (2nd byte code * 256) + (3rd byte code * 2562) ...
Syntax:
ORD(str)
Argument:
Name | Description |
---|---|
str | A string. |
Syntax Diagram:

MySQL Version: 5.6
Video Presentation:
Example: MySQL ORD() function
The following MySQL statement returns 119.
Code:
SELECT ORD("w3resource");
Sample Output:
mysql> SELECT ORD("w3resource"); +-------------------+ | ORD("w3resource") | +-------------------+ | 119 | +-------------------+ 1 row in set (0.00 sec)
All String Functions
Previous: OCTET_LENGTH
Next: POSITION
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises