MySQL HEX Function

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

SELECT HEX(N)

SELECT HEX(String_Value);

MySQL Hexadecimal Function Example

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

SELECT HEX(10);

SELECT HEX(2500);

SELECT HEX(1900), HEX(34567890);
HEX Example 1

Let me take another example to show the HEX String method. If we specify the text or words as the argument, then this MySQL method 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