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.
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…