# CONV

## Syntax

```sql
CONV(N,from_base,to_base)
```

## Description

Converts numbers between different number bases. Returns a string representation of the number *`N`*, converted from base *`from_base`* to base *`to_base`*.

Returns `NULL` if any argument is `NULL`, or if the second or third argument are not in the allowed range.

{% tabs %}
{% tab title="Current" %}
The argument *`N`* is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 62. If *`to_base`* is a negative number, *`N`* is regarded as a signed number. Otherwise, *`N`* is treated as unsigned. `CONV()` works with 64-bit precision.
{% endtab %}

{% tab title="< 11.4" %}
The argument *`N`* is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If *`to_base`* is a negative number, *`N`* is regarded as a signed number. Otherwise, *`N`* is treated as unsigned. `CONV()` works with 64-bit precision.
{% endtab %}
{% endtabs %}

Some shortcuts for this function are also available: [BIN()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin), [OCT()](https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/oct), [HEX()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/hex), [UNHEX()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/unhex). Also, MariaDB allows [binary](https://mariadb.com/docs/server/reference/sql-structure/sql-language-structure/binary-literals) literal values and [hexadecimal](https://mariadb.com/docs/server/reference/sql-structure/sql-language-structure/hexadecimal-literals) literal values.

## Examples

```sql
SELECT CONV('a',16,2);
+----------------+
| CONV('a',16,2) |
+----------------+
| 1010           |
+----------------+

SELECT CONV('6E',18,8);
+-----------------+
| CONV('6E',18,8) |
+-----------------+
| 172             |
+-----------------+

SELECT CONV(-17,10,-18);
+------------------+
| CONV(-17,10,-18) |
+------------------+
| -H               |
+------------------+

SELECT CONV(12+'10'+'10'+0xa,10,10);
+------------------------------+
| CONV(12+'10'+'10'+0xa,10,10) |
+------------------------------+
| 42                           |
+------------------------------+
```

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
