Collections:
ASCII() - ASCII Value of First Character
How to get the ASCII value of the first character of the a given string using the ASCII() function?
✍: FYIcenter.com
ASCII(string) is a MySQL built-in function that returns the
ASCII value of the first character of a giving string. For example:
SELECT ASCII('dba.FYIcenter.com');
-- +----------------------------+
-- | ASCII('dba.FYIcenter.com') |
-- +----------------------------+
-- | 100 |
-- +----------------------------+
SELECT ASCII('O'), ASCII('©'), ASCII('😋');
-- +------------+-------------+---------------+
-- | ASCII('O') | ASCII('©') | ASCII('😋') |
-- +------------+-------------+---------------+
-- | 79 | 194 | 240 |
-- +------------+-------------+---------------+
SELECT HEX('O'), HEX('©'), HEX('😋');
-- +----------+-----------+-------------+
-- | HEX('O') | HEX('©') | HEX('😋') |
-- +----------+-----------+-------------+
-- | 4F | C2A9 | F09F988B |
-- +----------+-----------+-------------+
Reference information of the ASCII() function:
ASCII(str): num
Returns the numeric value of the leftmost character of the string str.
Returns 0 if str is the empty string. Returns NULL if str is NULL.
ASCII() works for 8-bit characters.
Arguments, return value and availability:
str: Required. The given string to return the ASCII value
of the first characters for.
num: Return value. The ASCII value of the first character.
Available since MySQL 4.0.
Related MySQL functions:
⇒ BIT_LENGTH() - Number of Bits in String
⇐ MySQL Functions on Character String Values
2023-11-11, 1426🔥, 0💬
Popular Posts:
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
How To Insert New Line Characters into Strings in SQL Server Transact-SQL? If you want to break a st...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...
How To Install PHP on Windows in MySQL? The best way to download and install PHP on Windows systems ...
How To Get the Definition of a User Defined Function Back in SQL Server Transact-SQL? If you want ge...