How to View Bit Values in MySQL Query Browser

I stumbled across this useful tidbit the other day in the MySQL Forums. I’ve always been frustrated that bit data type values fail to appear in MySQL Query Browser. Instead, it simply displays a ‘b’ regardless of the actual value.

I looked through all of the options but couldn’t find a setting related to the issue. The solution (workaround) turned out to be very easy. Just add 0 to the column in the SELECT list and the values will appear.

For example:

SELECT myBooleanColumn + 0 as myBooleanColumn
FROM myTable

Either a 1 or a 0 will now appear as the value in the results.

2 thoughts on “How to View Bit Values in MySQL Query Browser

  1. Hi Glenn,

    I am using MySQL on Mac and I encountered this issue. Ok, by adding 0 it works on my query browser.

    The problem now is, through Java and Hibernate, I retrieve the value of the column and mapped it to a class field of type Boolean. This time, the field is always false because converting a string “b” to Boolean is always false.

  2. Hi Mohammad,

    The field value isn’t actually a “b”. That’s just how it’s represented in the Query Browser. The actual value is a 0 or a 1. That’s why adding 0 to it returns a number. In the actual application there is no need to add a zero.

    MySQL would not allow a “b” to be stored in a non-character column so you must be having a different issue in your application.


Comments are closed.