MySQL always returning BIT values as blank MySQL always returning BIT values as blank mysql mysql

MySQL always returning BIT values as blank


You need to cast the bit field to an integer.

mysql> select hasMultipleColors+0 from pumps where id = 1;

This is because of a bug, see: http://bugs.mysql.com/bug.php?id=43670. The status says: Won't fix.


You can cast BIT field to unsigned.

  SELECT CAST(hasMultipleColors AS UNSIGNED) AS hasMultipleColors   FROM pumps   WHERE id = 1

It will return 1 or 0 based on the value of hasMultipleColors.


You need to perform a conversion as bit 1 is not printable.

SELECT hasMultipleColors+0 from pumps where id = 1;

See more here:http://dev.mysql.com/doc/refman/5.0/en/bit-field-literals.html