Home > Database > Mysql Tutorial > How to use the BIN() function in MySQL?

How to use the BIN() function in MySQL?

藏色散人
Release: 2019-03-12 13:56:16
Original
3432 people have browsed it

The BIN() function in MySQL is used to convert a decimal number into a binary number. The BIN() function is equivalent to the CONV() function, and its format is CONV(number,10,2). The function of the function is to convert the number "number" with base 10 (decimal) into a number with base 2 (binary).

How to use the BIN() function in MySQL?

BIN() function syntax:

BIN( NUM )
Copy after login

Parameters:
NUM: It is to find its binary equivalent decimal number.

Return value:
The BIN() function returns a string value, which is the binary equivalent of the decimal number passed as a parameter. If the number is NULL, return NULL.

Example 1:

Convert 5 to its binary equivalent.
Syntax:

How to use the BIN() function in MySQL?

Output:

'101'
Copy after login

Example 2:

Convert 12 to binary etc. Effectiveness value.
Syntax:

How to use the BIN() function in MySQL?

Output:

'1100'
Copy after login

Example 3:

Convert 97 to binary etc. Effectiveness value.
Grammar:

How to use the BIN() function in MySQL?

Output:

'1100001'
Copy after login

Related mysql video tutorial recommendation: "mysql tutorial"

This article is an introduction to the BIN() function in MySQL. I hope it will be helpful to friends in need!

The above is the detailed content of How to use the BIN() function in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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