Computer >> Computer tutorials >  >> Programming >> MySQL

What is the use of MySQL UNHEX() function?


As its name suggests, it is the opposite of HEX() function. Basically, UNHEX() function converts the hexadecimal number into the byte represented by the number. The value returned by it would be a binary string.

Syntax

UNHEX(str)

Here, str is a string which is to be converted into the byte represented by the number. The characters in the str must be a valid hexadecimal digit.

Example

mysql> Select UNHEX('5475746F7269616C73706F696E74');
+---------------------------------------+
| UNHEX('5475746F7269616C73706F696E74') |
+---------------------------------------+
| Tutorialspoint                        |
+---------------------------------------+
1 row in set (0.00 sec)