Home > Database > Mysql Tutorial > body text

How do we enter a value as a BINARY number in a MySQL statement?

WBOY
Release: 2023-08-26 15:33:06
forward
1409 people have browsed it

我们如何在 MySQL 语句中以 BINARY 数字的形式输入数值?

Here are the two ways in which we can enter binary numeric values-

Press prefix 'B'

This method requires quoting the binary number within single quotes with the B prefix, and then the BINARY numeric string will be automatically converted to a numeric value based on the expression context.

Example

mysql> Select B'1110'+0;
+-----------+
| B'1110'+0 |
+-----------+
|        14 |
+-----------+
1 row in set (0.00 sec)
Copy after login

By prefix 0b

In this method we need to write the BINARY number without quotes with prefix 0b. The BINARY numeric string will then be automatically converted to a numeric value based on the expression context.

Example

mysql> Select 0b1110+0;
+----------+
| 0b1110+0 |
+----------+
|       14 |
+----------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How do we enter a value as a BINARY number in a MySQL statement?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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!