Set bit to TRUE/FALSE

Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Set bit to TRUE/FALSE

Post 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?
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: Set bit to TRUE/FALSE

Post 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.
Post Reply