3 conversion methods: 1. Use the BIN() function to return the string representation of the binary value of the specified number. The syntax is "BIN(number)". The parameter "number" is a long integer ( BIGINT) number. 2. Use the CONV() function to convert one base to another. The syntax "CONV(number,10,2)" can return the binary value of the specified number. 3. Use the BINARY function to convert the value into a binary string, with the syntax "BINARY "value"".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
MySQL has three methods to convert values to binary
Method 1: Use the BIN() function
The BIN() function returns the binary representation of a number as a string value; that is, the string representation of the binary value of a number.
BIN(number)
Parameter | Description |
---|---|
number | Required item. A long integer (BIGINT) number |
Example:
Returns the binary representation of 15
SELECT BIN(15);
Return the binary representation of 8
Method 2: Use the CONV() function
The CONV() function can Convert between digits, that is, convert between arbitrary bases.
CONV(number,10,2)
is equivalent to BIN(number)
.
Example:
Return the binary representation of 15
##Method 3: Use the BINARY function
BINARY function converts a value to a binary type string.SELECT BINARY "值";Example:
SELECT BINARY "15";[Related recommendations:
mysql video tutorial]
The above is the detailed content of How to convert value to binary in mysql. For more information, please follow other related articles on the PHP Chinese website!