hex
Description
Syntax:
VARCHAR hex(VARCHAR str)
VARCHAR hex(BIGINT num)
If the input argument is a number, this function will return the hexadecimal string representation of the number.
If the input argument is a string, it will convert each character to two hexadecimal characters, and concatenate them into a string.
Example
input string
mysql> select hex('1');
+----------+
| hex('1') |
+----------+
| 31 |
+----------+
mysql> select hex('@');
+----------+
| hex('@') |
+----------+
| 40 |
+----------+
mysql> select hex('12');
+-----------+
| hex('12') |
+-----------+
| 3132 |
+-----------+
intput num
mysql> select hex(12);
+---------+
| hex(12) |
+---------+
| C |
+---------+
mysql> select hex(-1);
+------------------+
| hex(-1) |
+------------------+
| FFFFFFFFFFFFFFFF |
+------------------+
Keywords
HEX