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!
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. value is a binary value written using zeros and ones.
MySQL has support for full-text indexing and searching: A full-text index in MySQL is an index of type FULLTEXT . Full-text indexes can be used only with InnoDB or MyISAM tables, and can be created only for CHAR , VARCHAR , or TEXT columns.
If you want to select only specific columns, replace the * with the names of the columns, separated by commas. The following statement selects just the name_id, firstname and lastname fields from the master_name table.
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.
SELECT * FROM table WHERE active = (1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With