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.
Toys have always played a crucial role in childhood, fueling imagination, creativity, and learning. Whether you're looking for educational playsets,…
Toys are an essential part of childhood, shaping creativity, learning, and fun-filled memories. Whether it’s the soft embrace of plush…
Toys are a gateway to imagination, creativity, and learning. Whether it’s a child’s first plush toy, a set of engaging…
Toys are more than just playthings; they help children explore, learn, and develop essential life skills. From interactive sensory toys…
Toys are more than just playthings; they are tools that foster creativity, motor skills, and cognitive development in children. From…
Toys play an integral role in a child’s growth and development. They spark creativity, encourage learning, and provide endless hours…