Home > Database > Mysql Tutorial > body text

How to convert data to binary in mysql

青灯夜游
Release: 2022-03-17 14:10:51
Original
4062 people have browsed it

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);
Copy after login

Example: Return the binary representation of 111

SELECT BIN(111);
Copy after login

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 "数据值";
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!