UNHEX() Function in MySQL
UNHEX() function in MySQL is used to convert the Hexadecimal number into the bytes represented by the Number. The value returned by it is a binary string.
Syntax :
UNHEX(str)
Parameter : Required.
str : It is a string which is to be converted into the byte represented by the number.
Returns : It returns a binary string. If non-hexadecimal digits are provided this function returns NULL.
Example-1 :
Using UNHEX() function to a string.
SELECT UNHEX('6765656B73666F726765656B73') AS String_Name;
Output :
String_Name |
---|
w3wiki |
Example-2 :
Using UNHEX() function to another string.
SELECT UNHEX('48656C6C6F') AS String_Name;
Output :
String_Name |
---|
Hello |
Example-3 :
Using UNHEX() function to a non-hexadecimal string.
SELECT UNHEX('www') AS String_Name;
Output :
String_Name |
---|
NULL |