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

How to use the BIN() function in MySQL?

藏色散人
藏色散人Original
2019-03-12 13:56:163380browse

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 )

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'

Example 2:

Convert 12 to binary etc. Effectiveness value.
Syntax:

How to use the BIN() function in MySQL?

Output:

'1100'

Example 3:

Convert 97 to binary etc. Effectiveness value.
Grammar:

How to use the BIN() function in MySQL?

Output:

'1100001'

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!

Statement:
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