3 messages in com.mysql.lists.mysqlRe: Antwort: boolean type
FromSent OnAttachments
alex...@delphiauto.com01 Mar 2001 01:53 
Thalis A. Kalfigopoulos01 Mar 2001 10:38 
Robert Vetter02 Mar 2001 06:28 
Subject:Re: Antwort: boolean type
From:Thalis A. Kalfigopoulos (tha@cs.pitt.edu)
Date:03/01/2001 10:38:49 AM
List:com.mysql.lists.mysql

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