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 -
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)
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!