Page 1 of 1

Set bit to TRUE/FALSE

Posted: Wed Aug 29, 2012 8:16 pm
by mister_v
Hello,

I'm trying to store a value in a BIT data type as True/False

Code: Select all

CREATE TABLE test
(
  id VARCHAR(40) PRIMARY KEY,
  value BIT DEFAULT FALSE
);
But I have troubles to set it to True.
It also doesn't show FALSE when I do a select.

Anyone know how to solve this?

Re: Set bit to TRUE/FALSE

Posted: Thu Aug 30, 2012 3:30 pm
by chris
You can use TININT(1) to set a value of 1 bit (0 or 1).

But my personal favorite is EMNUM

Code: Select all

valuename enum('true','false') NOT NULL default 'false'
note: ENUM can have more then 2 values, up to 65,535.