The MySQL string ORD function is one of the String Function, which is used to find the code of the leftmost character in a string.
- If the leftmost character is a multibyte character, it uses the formula to calculate the code: (1st byte code) + (2nd byte code *256) + (3rd byte code * 256^2)… .
- If the leftmost character is not a multibyte character, this function writes the ASCII code of that byte.
In this article, we will show you, How to write a String Ord in MySQL to find the string code with an example.
MySQL String ORD Syntax
The basic syntax of the ORD string in MySQL is as shown below.
MySQL ORD Function Example
The following query will show multiple ways to use this MySQL String ORD function. Here, we used only single characters, that’s why, this function returns the ASCII values of that characters.
Within the first two statements, we used multiple value. However, this function will return the ASCII value of first character.
In the third statement, we used different character. So, it used the formula to get that code.
Thank You for Visiting Our Blog