Why not try using ENUM?

http://www.mysql.com/doc/E/N/ENUM.html

You could setup your table like this:

CREATE TABLE logInfo2
(
    logID           INT NOT NULL UNIQUE,
    ipAddress       VARCHAR(20) NOT NULL DEFAULT 'None',
    boolVars        ENUM ('T', 'F') DEFAULT 'F'
)

SELECT ipAddress FROM logInfo2 WHERE boolVars = 'F';

-----Original Message-----
From: russ [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 06, 2001 9:10 AM
To: [EMAIL PROTECTED]
Subject: Boolean Datatype


Im new to the list, apologies if this has been asked before.

Im developing a backend for a personal site (www.russd.com) using mySQL.
The site is hosted on NT4 and has myODBC installed, I have some database
access working, but I'm looking for a way to implement boolean types.

Using Access/SQL server I can simple do an insert using SQL like the
following (from within ASP):

INSERT INTO tblMyTable (booleanField) VALUES (" & myBooleanVariant & ");"

Unfortunately, mySQL doesn't appear to have a boolean datatype and myODBC
doesn't seem to convert True/False to 1/0.
The best solution I have so far is to use a TINYINT and change the
True/False values within my ASP code to 1/0. This isn't perfect howevere as
its more code, more work for the server and far less readable. I also have
to cast to boolean when I SELECT data from the mySQL database.

Could anyone suggest a better way of implementing this, or am I missing
something?
I have done a Google search and searched the mySQL manual, but got nothing.

Many thanks in advance of your efforts.
Russ Davies

---------------------------------------------------------------------
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

---------------------------------------------------------------------
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