"Thalis A. Kalfigopoulos" wrote:
>
> > > 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
I don't quite understand this. How is it possible to story an 1-bit
value in a file or memory and use exactly only 1 bit for it? As far as I
know compters can access at least 1 byte-8 bits at one time, not less.
Does MySQL use a special algorithm in this case?
Robert
---------------------------------------------------------------------
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