This function helps in getting the numeric value of the leftmost character of a input string.
[table caption=”” width=”100%” colwidth=”50%|50%” colalign=”left|left”]
If the leftmost character, returned value
is a multibyte character, the returned value is calculated from the numeric values of its constituent bytes.
is not a multibyte character, the return value is its ASCII code (i.e it gives similar value which ASCII() function returns) .
[/table]
ORD( string );
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional, Value Type, Description
string , Required, String , This is input string from which we want the numeric code of the first character from starting.
[/table]
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
Number, returns the numeric value of the leftmost character of the input string.
[/table]
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 5.7
[/table]
mysql> SELECT ORD('Tuts'); +-------------+ | ORD('Tuts') | +-------------+ | 84 | +-------------+ 1 row in set (0.00 sec)
Ascii value for the e.g.1 is same for both input. Both function returns same values.
mysql> SELECT ORD('T'), ASCII('T'); +----------+------------+ | ORD('T') | ASCII('T') | +----------+------------+ | 84 | 84 | +----------+------------+ 1 row in set (0.00 sec)
Below example will have multibyte character. So, returned values are calculated from the numeric values of its constituent bytes.
mysql> SELECT ORD('€'), ORD('§'); +------------+-----------+ | ORD('€') | ORD('§') | +------------+-----------+ | 14844588 | 49831 | +------------+-----------+ 1 row in set (0.00 sec)
It will return NULL, if the argument is NULL. Lets see the below example.
mysql> SELECT ORD(NULL); +-----------+ | ORD(NULL) | +-----------+ | NULL | +-----------+ 1 row in set (0.00 sec)
Uppercase and Lowercase characters have a different numeric value. Hence, it is Case Sensitive function for alphabets. Below example will show this:
mysql> SELECT ORD('A'), ORD('a'), ASCII('A'), ASCII('a'); +----------+----------+------------+------------+ | ORD('A') | ORD('a') | ASCII('A') | ASCII('a') | +----------+----------+------------+------------+ | 65 | 97 | 65 | 97 | +----------+----------+------------+------------+ 1 row in set (0.00 sec)
See all MySQL String functions MySQL 8 String Functions.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…