Mysql: How to query a column whose type is bit?

Luixv picture Luixv · May 8, 2009 · Viewed 38.7k times · Source

Hi I am using hibernate and Mysql. I have a class with a boolean attribute called 'active'.

The generated database table has the BIT data type. So far so good. I want to query this value but I don't know how to do it. I've tried

 SELECT * from table where active = 1

doesn't work, neither the following

 SELECT * from table where active = true

I didn't find anything neither in the reference manual nor at Stackoveflow.

Any hint?

Thanks in advance!

Answer

Peter D picture Peter D · May 8, 2009
SELECT * FROM table WHERE active = (1)