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

后端 未结 6 1777
离开以前
离开以前 2020-12-08 14:31

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 w

6条回答
  •  鱼传尺愫
    2020-12-08 15:05

    According to this page, BIT is a synonym for TINYINT(1) for versions before 5.0.3.

    Have you tried these?

    SELECT * from table where active = (1)
    SELECT * from table where active = 'true'
    SELECT * from table where active = b'1'
    

    This blog entry suggests to avoid the BIT data type altogether.

提交回复
热议问题