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

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

王林
Release: 2023-09-03 11:37:11
forward
718 people have browsed it

我们如何以可打印的形式显示 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)
Copy after login

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

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!

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