MySQL HEX Function

MySQL HEX function is one of the String Functions, which is to convert the given value to the Hexadecimal number. And the MySQL HEX function returns the string representation of that Hexadecimal number. The basic syntax of the HEX Function is

SELECT HEX(N)

SELECT HEX(String_Value);

MySQL Hexadecimal Function Example

The Hexadecimal Function in MySQL converts the user specified number or String to Hexadecimal Number. Next, it returns the Output in String format. The following query shows you multiple ways to use this HEX function on Numeric values.

SELECT HEX(10);

SELECT HEX(2500);

SELECT HEX(1900), HEX(34567890);
MySQL HEX Function 1

Let me take another example to show the HEX(String) String Function. If we specify the string value as the argument, then this MySQL function converts each byte of a character in a string into a hexadecimal digit.

SELECT HEX('Hi');

SELECT HEX('Tutorial Gateway');

SELECT HEX('MySQL');
MySQL HEX Function 2