> > Is there a boolean field type (Yes/No; True/False, 1/0)  in MySQL or what is
> > closest to the boolean type
> 
> ShortInt: 0 == FALSE, <> 0 == TRUE
> That's how I do it anyway.
> 
> Or maybe combine multiple bool fields to one and use binary logic.


Or quoting from http://www.bitbybit.dk/mysqlfaq/faq.html

Q: create a column of type BOOLEAN?

MySQL does not have a boolean type per se. The usual way to create a boolean value, is 
to use the ENUM type:
mysql> CREATE TABLE truths 
        -> (answer ENUM('true','false') NOT NULL);

(don't forget the NOT NULL clause, or you end up having not two, but three legal 
values for the field.)

You can also use the following hack to define a field which can contain only one of 
two values, namely the empty string ("") or NULL:

mysql> CREATE TABLE truths 
        -> (answer CHAR(0));

The special beauty of the second example is that the data in the field only occupies 
one bit, as opposed to an ENUM field, which always occupies at least a byte. However, 
you get to do quite a bit of encoding and decoding of these values on your front end...

regards,
thalis


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to