I have a Java application and have mapped a boolean field to a bit(1) field in MySql.
I know for sure that some rows have the value set to true and some to false, however, I can't see it from the mysql console - which is annoying when you try to debug things and understand what is going on.
Is it possible to configure mysql to display the bit(1) fields in a friendly manner?
mysql> select ignored from table; +---------+ | ignored | +---------+ | | | | | | | | | | | | | | | | | | | | +---------+ 10 rows in set (0.00 sec)
BIT is a data type used in MySQL that allows us to store bit values. The bit value comes in a range of 1-64. It will store values only in 0 and 1. If we store a bit value like 2, it will return an error message. Generally, we can define the bit value with the create table or defining statements.
The BIT data type is used to store bit values. A type of BIT( M ) enables storage of M -bit values. M can range from 1 to 64. To specify bit values, b' value ' notation can be used.
To return only the first row that matches your SELECT query, you need to add the LIMIT clause to your SELECT statement. The LIMIT clause is used to control the number of rows returned by your query. When you add LIMIT 1 to the SELECT statement, then only one row will be returned.
select ignored+0 from table;
select cast(ignored as unsigned) from table;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With