Product Solutions Support
Try MemSQL

HEX

Returns the hexadecimal representation of numeric, string, or binary data.

HEX (expression)

Arguments

Return Type

Upper-case hexadecimal string.

Examples

memsql> select hex(1234);
+-----------+
| hex(1234) |
+-----------+
| 4D2       |
+-----------+

memsql> select hex('1234');
+-------------+
| hex('1234') |
+-------------+
| 31323334    |
+-------------+

memsql> select hex('ohai');
+-------------+
| hex('ohai') |
+-------------+
| 6F686169    |
+-------------+
Info

This function operates on the binary representation of the given argument. That is why the result of hex(1234) and hex('1234') yield different values. This also means that the output of hex( number ) cannot be fed into UNHEX directly to get back the literal number 1234.

Was this article useful?