Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't see bit(1) fields in mysql

Tags:

database

mysql

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)
like image 340
flybywire Avatar asked Oct 05 '09 11:10

flybywire


People also ask

What is bit 1 in MySQL?

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.

Does MySQL have bit?

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.

How do I get only one record in MySQL?

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.


2 Answers

select ignored+0 from table;
like image 169
dnagirl Avatar answered Oct 23 '22 05:10

dnagirl


select cast(ignored as unsigned) from table;
like image 29
Kimvais Avatar answered Oct 23 '22 05:10

Kimvais