Skip to main content

CONV

Description

Do radix conversion for input parameter.

Syntax

CONV(<input>, <from_base>, <to_base>)

Parameters

ParameterDescription
<input>Parameters to be converted, either as strings or integers
<from_base>Numeric, the source base, within [2,36].
<to_base>Numeric, the target base, within [2,36].

Return Value

The number under the converted target binary <to_base> is returned as a string. When any input parameter is NULL, returns NULL. If <from_base> or <to_base> does not meet the range requirement, returns NULL.

Examples

SELECT CONV(15,10,2);
+-----------------+
| conv(15, 10, 2) |
+-----------------+
| 1111 |
+-----------------+
SELECT CONV('ff',16,10);
+--------------------+
| conv('ff', 16, 10) |
+--------------------+
| 255 |
+--------------------+
SELECT CONV(230,10,16);
+-------------------+
| conv(230, 10, 16) |
+-------------------+
| E6 |
+-------------------+
SELECT CONV(230,10,NULL);
+-------------------+
| CONV(230,10,NULL) |
+-------------------+
| NULL |
+-------------------+
SELECT CONV(230,10,56);
+-----------------+
| CONV(230,10,56) |
+-----------------+
| NULL |
+-----------------+