473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

yes/no data type

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
Aug 2 '06 #1
5 43369
"Dave" <da***@nospam.co.ukwrote in message
news:Bq******************@newsfe3-gui.ntli.net...
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
Aug 2 '06 #2
"Thomas Bartkus" <th***********@comcast.netwrote in message
news:UM******************************@telcove.net. ..
"Dave" <da***@nospam.co.ukwrote in message
news:Bq******************@newsfe3-gui.ntli.net...
>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
Aug 2 '06 #3
"Dave" <da***@nospam.co.ukwrote in message
news:O0******************@newsfe7-win.ntli.net...
"Thomas Bartkus" <th***********@comcast.netwrote in message
news:UM******************************@telcove.net. ..
"Dave" <da***@nospam.co.ukwrote in message
news:Bq******************@newsfe3-gui.ntli.net...
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

Aug 2 '06 #4
>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.
You can try an enum type:

enum('No', 'Yes')

Gordon L. Burditt
Aug 3 '06 #5

"Thomas Bartkus" <th***********@comcast.netwrote in message
news:Ze******************************@telcove.net. ..
"Dave" <da***@nospam.co.ukwrote in message
news:O0******************@newsfe7-win.ntli.net...
>"Thomas Bartkus" <th***********@comcast.netwrote in message
news:UM******************************@telcove.net ...
"Dave" <da***@nospam.co.ukwrote in message
news:Bq******************@newsfe3-gui.ntli.net...
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
Aug 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
5
by: Eternally | last post by:
Hey folks, To me, this sounds like a crazy question, but I'll throw it out there anyway. Is it possible to change a variables data type half way through a running program? If so, how? ...
13
by: dawatson833 | last post by:
I have several stored procedures with parameters that are defined with user defined data types. The time it takes to run the procedures can take 10 - 50 seconds depending on the procedure. If I...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
6
by: Mike Hoff | last post by:
I am trying to write a class that will store info about database fields for building UPDATE / INSERT commands later on. I cannot seem to get the sytax correct to pass and store the data type of...
13
by: Fei Liu | last post by:
Hi Group, I've got a problem I couldn't find a good solution. I am working with scientific data files in netCDF format. One of the properties of netCDF data is that the actual type of data is only...
6
by: RickH | last post by:
Hello, I would like to create a user XSD data type that inherits from the w3 standard data type called ID to make sure a certain repeated element always contains distinct values. The problem is...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
8
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.