Many thanks to all for the help on this issue.
I've come to the conclusion the simplest way for me to implement this is to use the 
ENUM type with two possible values 'True' and 'False'.
I will convert the VB BOOLEAN type to a string before I enter it.

Thankfully when returning a value from mySQL, ASP detects the string is "True" and it 
evaluates succesfully  ("true" = True)

Many thanks for everyones help on a relatively simple question, you've been really 
good. I've taken enough of your time now...

Russ Davies

---------- Original Message ----------------------------------
From: [EMAIL PROTECTED]
Date: Wed, 7 Feb 2001 10:14:14 +0100

>
>On 06.02.2001 18:09:36 russ wrote:
>
>> 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 & ");"
>
>Okay, define booleanField to be TinyINT, or maybe ENUM('TRUE', 'FALSE'), but
>TinyINT would be a lot easier IMO.
>Then for FALSE you'd insert a 0 and for TRUE you'd insert something else.
>
>> values within my ASP code to 1/0. This isn't perfect howevere as its more
>code,
>
>Why?  Dunno about ASP but since it's from M$ it must be superior to PHP *G* and
>in PHP you'd simply do this:
>
>$q = "INSERT INTO tblMyTable (booleanField) VALUES ('" . ( "yes" == "no" ) .
>"')";
>$rs = mysql_query( $q );
>
>Now booleanField would be set to a FALSE value, or:
>
>$q = "INSERT INTO tblMyTable (booleanField) VALUES ('" . ( "answer to life,
>universe and everything" == "42" ) . "')";
>$rs = mysql_query( $q );
>
>This time, we'd have set your booleanField to TRUE *G*  (well, sorta :]).
>
>$q = "SELECT booleanField FROM tblMyTable WHERE Something=42";
>$rs = mysql_query( $q );
>$row = mysql_fetch_object( $rs );
>
>if( $row->booleanField ){(
>     // booleanField is anything but 0, ie. it's TRUE
>} else {
>     // booleanField is 0, ie. it is FALSE
>}
>
>In how far is this more code??
>
>> Could anyone suggest a better way of implementing this, or am I missing
>> something?
>
>Yeah, you're missing something.  In many languages there's no bool data type,
>basically, because something like a tinyINT handles this very well.
>
>
>

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