What is the usage of the hex function in MySQL?

In MySQL, the HEX() function is used to convert a string into a hexadecimal value. The syntax is as follows:

HEX(str)

The string is to be converted to hexadecimal value. The HEX() function returns a string containing the hexadecimal representation of each character in the string. If the input string is empty, an empty string is returned.

For example, you can use the HEX() function to convert the string ‘Hello’ to hexadecimal value.

SELECT HEX('Hello');

The output results are:

48656C6C6F
Leave a Reply 0

Your email address will not be published. Required fields are marked *