Conversion method: 1. Use the BIN() function, the syntax "SELECT BIN(number)"; 2. Use the BINARY() function, the syntax "SELECT BINARY "value""; 3. Use the CAST() function , syntax "SELECT CAST(value AS BINARY)".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
mysql converts data to binary
##Method 1: Use the BIN() function
The BIN() function returns the binary representation of a number as a string value. Syntax:SELECT BIN(number);Example: Return the binary representation of 111
SELECT BIN(111);##Method 2: Using the BINARY() function
The BINARY function converts a value into a binary string.
Syntax:
SELECT BINARY "数据值";Method 3: Use the CAST() function
The CAST() function converts a value (of any type) to a specified type of data.
CAST(value AS BINARY) has the same function as the BINARY() function, converting the value into a binary string.
The above is the detailed content of How to convert data to binary in mysql. For more information, please follow other related articles on the PHP Chinese website!