Home > Database > Mysql Tutorial > 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
Release: 2023-09-07 21:17:02
forward
670 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template