HEX
Descriptionβ
If the input parameter is a number, return the string representation of the hexadecimal value.
If the input parameter is a string, convert each character to two hexadecimal characters, concatenate all the converted characters into a string for output.
Syntaxβ
HEX ( <str> )
Parametersβ
Parameter | Description |
---|---|
<str> | Input parameter is a number or a string |
Return valueβ
The hexadecimal result of parameter <str>
.
Exampleβ
The input parameter is a number
SELECT HEX(12),HEX(-1)
+---------+------------------+
| hex(12) | hex(-1) |
+---------+------------------+
| C | FFFFFFFFFFFFFFFF |
+---------+------------------+
The input parameter is a string
SELECT HEX('1'),HEX('@'),HEX('12')
+----------+----------+-----------+
| hex('1') | hex('@') | hex('12') |
+----------+----------+-----------+
| 31 | 40 | 3132 |
+----------+----------+-----------+