Convert the input string into the corresponding byte sequence in hexadecimal.
TO_BINARY
TO_HEX(<str>)
| Parameter | Description |
|---|---|
<str> | The string data to be converted |
Return the decoded VARBINARY (displayed in hexadecimal format with a 0x prefix). Return NULL if any of the following conditions are met: The input is NULL; The input length is 0; The input length is odd; The input contains characters other than [0-9a-fA-F]; The length of the decoded result is 0 (decoding failed).
select to_hex(NULL),to_hex('a');
+----------------------------+--------------------------+ | to_hex(NULL) | to_hex('a') | +----------------------------+--------------------------+ | NULL | NULL | +----------------------------+--------------------------+
select to_hex('ab');
+----------------------------+ | to_hex('ab') | +----------------------------+ | 0xAB | +----------------------------+
select to_hex('000A');
+--------------------------------+ | to_hex('000A') | +--------------------------------+ | 0x000A | +--------------------------------+