This tutorial explains how to use the MySQL CONV function with syntax and examples.
The MySQL CONV function converts a number from one number base to another and returns the result as a string value.
The syntax for the CONV function in MySQL is:
CONV( number, from_base, to_base )
The number to convert.
The number base that the number is currently represented in. The from_base can be between 2 and 36.
The number base to convert to. The to_base can be between 2 and 36, or -2 and -36.
The CONV function can be used in the following versions of MySQL:
Let's look at some MySQL CONV function examples and explore how to use the CONV function in MySQL.
For example:
mysql> SELECT CONV(5, 10, 2);
Output: '101'
mysql> SELECT CONV(101, 2, 10);
Output: '5'
mysql> SELECT CONV(74, 10, 16);
Output: '4A'
mysql> SELECT CONV(-74, 10, -16);
Output: '-44
mysql> SELECT CONV('4A', 16, 10);
Output: '74'