Home  >  Article  >  Database  >  How can we display MySQL bit values ​​in printable form?

How can we display MySQL bit values ​​in printable form?

王林
王林forward
2023-09-03 11:37:11655browse

我们如何以可打印的形式显示 MySQL 位值?

Actually, the bit values ​​are returned in the form of binary values, but we can also display them in printable form with the help of the following command -

By adding 0

We can display the bit value in printable form by adding 0. You can understand it using the example in the bit_testing table -

mysql> Select bittest+0 from bit_testing;
+-----------+
| bittest+0 |
+-----------+
|       170 |
|         5 |
|         5 |
+-----------+
3 rows in set (0.00 sec)

By using the conversion function BIN(),OCT(),HEX()

We can also use the BIN() conversion function to Displays Bit values ​​in printable form. You can understand it using the example in bit_testing table -

mysql> Select BIN(bittest+0) from bit_testing;
+----------------+
| BIN(bittest+0) |
+----------------+
| 10101010       |
| 101            |
| 101            |
+----------------+
3 rows in set (0.00 sec)

mysql> Select OCT(bittest+0) from bit_testing;
+----------------+
| OCT(bittest+0) |
+----------------+
| 252            |
| 5              |
| 5              |
+----------------+
3 rows in set (0.05 sec)

mysql> Select HEX(bittest+0) from bit_testing;
+----------------+
| HEX(bittest+0) |
+----------------+
| AA             |
| 5              |
| 5              |
+----------------+
3 rows in set (0.00 sec)

The above is the detailed content of How can we display MySQL bit values ​​in printable form?. 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