Name

CONV( )

Synopsis

CONV(number, from_base, to_base)

This function converts a number from one numeric base system to another. The number to convert is given in the first argument, the base from which to convert the number in the second argument, and the base to which to convert the number in the third argument. The minimum base allowed is 2 and the maximum is 36.

SELECT CONV(4, 10, 2) AS 'Base-10 4 Converted',
CONV(100, 2, 10) AS 'Binary 100 Converted';
+---------------------+----------------------+
| Base-10 4 Converted | Binary 100 Converted |
+---------------------+----------------------+
| 100                 | 4                    |
+---------------------+----------------------+

Here the number 4 under the base 10 system is converted to the base-two or binary equivalent and back again.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.