ID EN
Mathematical Functions

CONV(N,from_base,to_base)

MySQL 8.4

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. 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 from_base is a negative number, N is regarded as a signed number. Otherwise, N is treated as unsigned. CONV() works with 64-bit precision.

Syntax

MYSQL
SELECT CONV('a',16,2);
'1010'
SELECT CONV('6E',18,8);
'172'
SELECT CONV(-17,10,-18);
'-H'
SELECT CONV(10+'10'+'10'+X'0a',10,10);
'40'

Examples

Example

CONV() returns NULL if any of its arguments are NULL.

MYSQL
SELECT CONV('a',16,2);
'1010'
SELECT CONV('6E',18,8);
'172'
SELECT CONV(-17,10,-18);
'-H'
SELECT CONV(10+'10'+'10'+X'0a',10,10);
'40'