If you want an enum to have the possible values of NULL or 1

alter table `Associate` modify `Active` enum('1');

from the mysql manual 
http://dev.mysql.com/doc/mysql/en/ENUM.html
If an ENUM column is declared to allow NULL, the NULL value is a legal
value for the column, and the default value is NULL. If an ENUM column
is declared NOT NULL, its default value is the first element of the list
of allowed values. 

If you simply want a column to hold boolean data I prefer to use
"tiyint(1) unsigned not null"
In my application I then treat 0 as False and 1 (or any other number) as
True

I do not believe you can make mysql evaluate NULL to be False, mysql
will evaluate 1 = True and 0 = False,
TRUE And FALSE are simply aliases for 1 and 0

you have two options

1) You could simply update your table
alter table `Associate` modify `Active` enum('0','1'); 
(or 1 then 0 if you want true to be the default)

then
update `Associate` set `Active` = 0 where isNull(Active);

2) modify your queries
select count(*) from Associate where Active!=1 OR isNull(Active);
select count(*) from Associate where Active=1;

Chris

-----Original Message-----
From: Scott Hamm [mailto:[EMAIL PROTECTED] 
Sent: 10 November 2004 14:25
To: 'Mysql ' (E-mail)
Subject: enum TRUE/FALSE

I'm trying to figure out how to make Active's null as FALSE and '1' as
TRUE, in enum point of view....

Can anyone help me out here, trying to learn enum's phenomenon? I'm not
sure I understood document quite clear -- as of yet.... :(


mysql> desc Associate;
+------------------+--------------+------+-----+---------+--------------
--+
| Field            | Type         | Null | Key | Default | Extra
|
+------------------+--------------+------+-----+---------+--------------
--+
| ID               | int(11)      |      | PRI | NULL    |
auto_increment |
| LocationID       | int(11)      | YES  |     | NULL    |
|
| NTLogon          | varchar(8)   | YES  |     | NULL    |
|
| DomainID         | int(11)      | YES  |     | NULL    |
|
| LastName         | varchar(30)  | YES  |     | NULL    |
|
| FirstName        | varchar(30)  | YES  |     | NULL    |
|
| Shift            | int(11)      | YES  |     | NULL    |
|
| QADE             | enum('','1') | YES  |     | NULL    |
|
| DataEntry        | enum('','1') | YES  |     | NULL    |
|
| QAMR             | enum('','1') | YES  |     | NULL    |
|
| MailRoom         | enum('','1') | YES  |     | NULL    |
|
| QAT              | enum('','1') | YES  |     | NULL    |
|
| Taping           | enum('','1') | YES  |     | NULL    |
|
| QAF              | enum('','1') | YES  |     | NULL    |
|
| Filming          | enum('','1') | YES  |     | NULL    |
|
| CustomerContact  | enum('','1') | YES  |     | NULL    |
|
| Trainee          | enum('','1') | YES  |     | NULL    |
|
| Active           | enum('','1') | YES  |     | NULL    |
|
| Creator          | varchar(8)   | YES  |     | NULL    |
|
| NewAssociateDate | date         | YES  |     | NULL    |
|
+------------------+--------------+------+-----+---------+--------------
--+
20 rows in set (0.00 sec)

mysql> select count(*) from Associate where Active=FALSE;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from Associate where Active=TRUE;
+----------+
| count(*) |
+----------+
|     2611 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from Associate;
+----------+
| count(*) |
+----------+
|     3947 |
+----------+
1 row in set (0.00 sec)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to