Home  >  Article  >  Database  >  How do we enter a value as a BINARY number in a MySQL statement?

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

WBOY
WBOYforward
2023-08-26 15:33:061411browse

我们如何在 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)

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete