> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv.md).

# CONV

## Syntax

```bnf
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()](/docs/server/reference/sql-functions/string-functions/bin.md), [OCT()](/docs/server/reference/sql-functions/numeric-functions/oct.md), [HEX()](/docs/server/reference/sql-functions/string-functions/hex.md), [UNHEX()](/docs/server/reference/sql-functions/string-functions/unhex.md). Also, MariaDB allows [binary](/docs/server/reference/sql-structure/sql-language-structure/binary-literals.md) literal values and [hexadecimal](/docs/server/reference/sql-structure/sql-language-structure/hexadecimal-literals.md) 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" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
