Open In App

UNHEX() Function in MySQL

Last Updated : 24 Sep, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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
geeksforgeeks



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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads