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).
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:
Output:
'101'
Example 2:
Convert 12 to binary etc. Effectiveness value.
Syntax:
Output:
'1100'
Example 3:
Convert 97 to binary etc. Effectiveness value.
Grammar:
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!