SelectCONV('10',10,2)AS'DECIMALTOBINARY';+-------------------+|"/> SelectCONV('10',10,2)AS'DECIMALTOBINARY';+-------------------+|">

Home  >  Article  >  Database  >  In MySQL, how do we convert a value from one number system to a value in another number system?

In MySQL, how do we convert a value from one number system to a value in another number system?

WBOY
WBOYforward
2023-09-07 21:17:02605browse

In MySQL, how do we convert a value from one number system to a value in another number system?

With the MySQL CONV() function, you can convert values ​​from one number system to another.

Syntax

CONV(N, from_base, to_base)

Here, "N" is the number to be converted, "from_base" is the current base of the number, and "to_base" is the base to which the number must be converted. "N" is interpreted as an integer, but can be specified as an integer or a string.

Example

mysql> Select CONV('10',10,2) AS 'DECIMAL TO BINARY';
+-------------------+
| DECIMAL TO BINARY |
+-------------------+
| 1010              |
+-------------------+
1 row in set (0.00 sec)

In the above example, the value 10 from decimal number system is being converted to binary number system.

The above is the detailed content of In MySQL, how do we convert a value from one number system to a value in another number system?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:MySQL client commandsNext article:MySQL client commands