Home  >  Article  >  Database  >  How to convert data to binary in mysql

How to convert data to binary in mysql

青灯夜游
青灯夜游Original
2022-03-17 14:10:514101browse

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)".

How to convert data to binary in mysql

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);

How to convert data to binary in mysql

##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.

    BINARY: Convert value to BINARY (binary string)
  • [Related recommendations:
mysql video tutorial

]

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!

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