On Sat, 1999-09-25 19:02:57 -0600, Hawke Robinson wrote:
> I am trying to setup some fields that accept only boolean
> (true/false) values.
On Sun, 1999-09-26 11:51:46 -0400, Bob Kline wrote:
> The two obvious choices would be the (standard) CHECK clause or the
> (non-standard) ENUM data type. Unfortunately the former doesn't do
> anything in MySQL, and the latter doesn't enforce the valid values:
> mysql> CREATE TABLE booltest(yes_or_no ENUM('yes', 'no') NOT NULL);
> Query OK, 0 rows affected (0.00 sec)
> mysql> INSERT INTO booltest VALUES ('maybe');
> Query OK, 1 row affected (0.00 sec)
> mysql> SELECT * FROM booltest;
> | yes_or_no |
> | |
> 1 row in set (0.00 sec)
> So yes, I'm afraid your assessment is correct; you must implement
> this by hand or use a related control table.
Just an idea: what's about ENUM('true')?
This field type only accepts 'true' and every other value maps to ''
meaning false then. Not a very nice solution though ...
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26 E4 EC 80 58 7B 31 3A D7