How to convert mysql to hexadecimal: 1. Use the hex() function, the syntax "select hex (decimal value);", to convert decimal to hexadecimal; 2. Use the conv() function , the syntax "select conv('data value', original base, 16);" can convert any base to hexadecimal.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
mysql converts data to hexadecimal
##Method 1: Use hex() function
hex() function can convert decimal to hexadecimal and return hexadecimal string representation. Syntax:HEX(N_or_S)
mysql> SELECT HEX(255); +---------------------------------------------------------+ | HEX(255) | +---------------------------------------------------------+ | FF | +---------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT 0x616263; +---------------------------------------------------------+ | 0x616263 | +---------------------------------------------------------+ | abc | +---------------------------------------------------------+ 1 row in set (0.00 sec)
Method 2: Use conv() function
CONV - hexadecimal conversion.CONV(N,from_base,to_base)
select conv('20',10,16);
Convert binary to decimal
select conv('101',2,10);
mysql video tutorial]
The above is the detailed content of How to convert data to hexadecimal in mysql. For more information, please follow other related articles on the PHP Chinese website!