HEX() FUNCTION in MySQL

HEX() FUNCTION
The MySQL HEX function is used to get a hexadecimal string for the specified string.

Syntax:

HEX( string )

Parameters:
string: It is used to specify the string to evaluate.

Example 1:

mysql> SELECT HEX ( ‘A’ );

Output:

41

Explanation:
The hex code of the string is returned.

Example 2:

mysql> SELECT HEX ( 1 );

Output:

31

Explanation:
The hex code of the number is returned.