MySQL Tutorial/Math Numeric Functions/CONV
Содержание
CONV(N,10,16).
<source lang="sql">
mysql> mysql> mysql> select CONV(10,10,16); +----------------+ | CONV(10,10,16) | +----------------+ | A | +----------------+ 1 row in set (0.00 sec) mysql></source>
CONV(N,10,2)
<source lang="sql">
mysql> select CONV(100,10,2); +----------------+ | CONV(100,10,2) | +----------------+ | 1100100 | +----------------+ 1 row in set (0.01 sec) mysql></source>
CONV(N,10,8)
<source lang="sql">
mysql> mysql> select CONV(256,10,8); +----------------+ | CONV(256,10,8) | +----------------+ | 400 | +----------------+ 1 row in set (0.00 sec) mysql></source>
CONV(N,from_base,to_base): Converts numbers between different number bases
Returns NULL if any argument is NULL.
The minimum base is 2.
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.
<source lang="sql">
mysql> mysql> SELECT CONV("a",16,2); +----------------+ | CONV("a",16,2) | +----------------+ | 1010 | +----------------+ 1 row in set (0.00 sec) mysql> mysql></source>
SELECT CONV(0xa,10,10);
<source lang="sql">
mysql> mysql> SELECT CONV(0xa,10,10); +-----------------+ | CONV(0xa,10,10) | +-----------------+ | 0 | +-----------------+ 1 row in set (0.00 sec) mysql></source>
SELECT CONV("10",10,10);
<source lang="sql">
mysql> mysql> mysql> mysql> SELECT CONV("10",10,10); +------------------+ | CONV("10",10,10) | +------------------+ | 10 | +------------------+ 1 row in set (0.01 sec) mysql></source>
SELECT CONV(-17,10,-18);
<source lang="sql">
mysql> mysql> mysql> SELECT CONV(-17,10,-18); +------------------+ | CONV(-17,10,-18) | +------------------+ | -H | +------------------+ 1 row in set (0.00 sec) mysql></source>