Click here to get back home

yes/no data type

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
yes/no data type Dave 08-02-2006
Get Chitika Premium
Posted by Dave on August 2, 2006, 7:57 am
Please log in for more thread options
Hello all

Is there a yes/no boolean datatype with mySQL? I can't seem to find if there
is, and I have used an int type set to 1 or 0 but that breaks some of my
apps that used to use access which does have a yes/no field.

Many thanks

Dave



Posted by Thomas Bartkus on August 2, 2006, 10:22 am
Please log in for more thread options
> Hello all
>
> Is there a yes/no boolean datatype with mySQL? I can't seem to find if
there
> is, and I have used an int type set to 1 or 0 but that breaks some of my
> apps that used to use access which does have a yes/no field.
>
> Many thanks
>
> Dave

That would be type "tinyint" for which the type "bool" is a synonym.
Access doesn't have a special boolean type either. It also uses an integer
numeric for "yes/no".

The yes/no true/false is all in the interpretation.
Thomas Bartkus



Posted by Dave on August 2, 2006, 2:19 pm
Please log in for more thread options
>> Hello all
>>
>> Is there a yes/no boolean datatype with mySQL? I can't seem to find if
> there
>> is, and I have used an int type set to 1 or 0 but that breaks some of my
>> apps that used to use access which does have a yes/no field.
>>
>> Many thanks
>>
>> Dave
>
> That would be type "tinyint" for which the type "bool" is a synonym.
> Access doesn't have a special boolean type either. It also uses an
> integer
> numeric for "yes/no".
>
> The yes/no true/false is all in the interpretation.
> Thomas Bartkus
>
>

When i query an access database which has a yes/no field with vbscript in
asp, the return i get is True or False but when I do the same query with
mySQL the return is 1 or 0.

Is this just the interpretation of the odbc driver or am i misinterpreting
it?

Thanks

Dave



Posted by Thomas Bartkus on August 2, 2006, 4:20 pm
Please log in for more thread options
> >> Hello all
> >>
> >> Is there a yes/no boolean datatype with mySQL? I can't seem to find if
> > there
> >> is, and I have used an int type set to 1 or 0 but that breaks some of
my
> >> apps that used to use access which does have a yes/no field.
> >>
> >> Many thanks
> >>
> >> Dave
> >
> > That would be type "tinyint" for which the type "bool" is a synonym.
> > Access doesn't have a special boolean type either. It also uses an
> > integer
> > numeric for "yes/no".
> >
> > The yes/no true/false is all in the interpretation.
> > Thomas Bartkus
> >
> >
>
> When i query an access database which has a yes/no field with vbscript in
> asp, the return i get is True or False but when I do the same query with
> mySQL the return is 1 or 0.
>
> Is this just the interpretation of the odbc driver or am i misinterpreting
> it?

I'm guessing it's an interpretation of the DAO or ADO database libraries
you are using with vbscript.

I presume that when you say "do the same query with mySQL", you are
referring to the MySQL command line client app. - yes/no ;-)

In MySQL, there is no real "boolean" flag attached to the field.
Try this:
SELECT True; # MySQL returns then integer 1
SELECT False; # MySQL returns the integer 0

The fact is, "True" and "False" are simple constants reflecting the integers
1 and 0 respectively.
More specifically, 0 is False and any number<> 0 is True.
Boolean algebra, Linux, MySQL running under Linux, and (I presume!) MySQL
running under Windows all follow this convention consistently.

As far as the MySQL command client is concerned, one needs to coerce it to
display the words "True" or "False"
SELECT IF(fld<>0, "True", "False")
or if you prefer:
SELECT IF(fld<>0, "Yes", "No")

I don't *think* there is any way to get that to happen automatically in the
MySQL command line client the way you can in Access. If you have linked
tables or pass through queries in Access that are speaking with MySQL
tables - these will never see a field labeled "boolean". You will have to
corece the type using the SELECT IF statements shown above.

But - That's a display/user interface issue.
The logic works exactly the way you would expect.

Thomas Bartkus




Posted by Dave on August 3, 2006, 6:56 am
Please log in for more thread options

>> >> Hello all
>> >>
>> >> Is there a yes/no boolean datatype with mySQL? I can't seem to find if
>> > there
>> >> is, and I have used an int type set to 1 or 0 but that breaks some of
> my
>> >> apps that used to use access which does have a yes/no field.
>> >>
>> >> Many thanks
>> >>
>> >> Dave
>> >
>> > That would be type "tinyint" for which the type "bool" is a synonym.
>> > Access doesn't have a special boolean type either. It also uses an
>> > integer
>> > numeric for "yes/no".
>> >
>> > The yes/no true/false is all in the interpretation.
>> > Thomas Bartkus
>> >
>> >
>>
>> When i query an access database which has a yes/no field with vbscript in
>> asp, the return i get is True or False but when I do the same query with
>> mySQL the return is 1 or 0.
>>
>> Is this just the interpretation of the odbc driver or am i
>> misinterpreting
>> it?
>
> I'm guessing it's an interpretation of the DAO or ADO database libraries
> you are using with vbscript.
>
> I presume that when you say "do the same query with mySQL", you are
> referring to the MySQL command line client app. - yes/no ;-)
>
> In MySQL, there is no real "boolean" flag attached to the field.
> Try this:
> SELECT True; # MySQL returns then integer 1
> SELECT False; # MySQL returns the integer 0
>
> The fact is, "True" and "False" are simple constants reflecting the
> integers
> 1 and 0 respectively.
> More specifically, 0 is False and any number<> 0 is True.
> Boolean algebra, Linux, MySQL running under Linux, and (I presume!) MySQL
> running under Windows all follow this convention consistently.
>
> As far as the MySQL command client is concerned, one needs to coerce it to
> display the words "True" or "False"
> SELECT IF(fld<>0, "True", "False")
> or if you prefer:
> SELECT IF(fld<>0, "Yes", "No")
>
> I don't *think* there is any way to get that to happen automatically in
> the
> MySQL command line client the way you can in Access. If you have linked
> tables or pass through queries in Access that are speaking with MySQL
> tables - these will never see a field labeled "boolean". You will have to
> corece the type using the SELECT IF statements shown above.
>
> But - That's a display/user interface issue.
> The logic works exactly the way you would expect.
>
> Thomas Bartkus
>
Thanks for the info Thomas



Similar ThreadsPosted
Data type question March 31, 2006, 6:36 am
Incorrect Column Type!! August 4, 2005, 11:05 am
enum type, sort, restrict, use January 11, 2006, 5:43 pm
checking "return type of sprintf" February 15, 2006, 9:23 am
Help: Invalid application buffer type April 28, 2006, 10:30 pm
Type All in Explain for Union Query August 11, 2006, 8:50 am
sort on column type enum September 26, 2006, 10:56 am
converting field type in active database October 30, 2005, 5:38 pm
product jpegs: best database field type: BLOB or filename? May 31, 2005, 9:32 am
Differences between DATA INFILE and LOAD DATA LOCAL INFILE ? June 26, 2005, 6:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap