473,503 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need some guidance with ENUM (logical) fields in MySQL

Hello all;

I have used dBASE, and other computer languages/databases, for years. They
all have a logical field type. However, the version of MySQL used by the ISP
hosting my site does not support a "logical" field type.

It does support ENUM and I have set some up in a couple of tables that
accept the values 'T' and 'F'. Sometimes they work like a logical field:

if ($myrow['new']) echo 'New';
else echo 'NOT new';

and other times I must use:

if ($myrow['new'] == 'T') echo 'New';
else echo 'NOT New';

I've been searching google and have only come up with some basic info --
such as use ENUM that allow '0' and '1'.

Before, I go off changing everything, can someone provide some insight in
using ENUM fields as logical and/or point me to a few good articles/web
pages?

TIA.

Charles...


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
Jul 20 '05 #1
7 2868
You can try

SELECT (new AND 1) as show FROM yourdatabase

If I'm correct

0 = first entry
1 = second entry
2 = 3rd entry
3 = 4th entry
...
If you use SET you can have multiple selected:

0 = none selected
1 = first item selected
2 =second item selected
3 = first & second item selected
4 = 3th item selected
5 = 1st + 3rd ..
6 = 2nd + 3rd
7 = 1st+2nd+3rd .

....

Maybe this helps.

or you can try:

SELECT (new="New") as show FROM yourdatabase
show==0 if not equal
show==1 if equal

:) Hope this helps a bit
Wouter

"Charles Crume" <cc@charlescrumesoftware.com> wrote in message
news:Ui*******************@fe2.columbus.rr.com...
: Hello all;
:
: I have used dBASE, and other computer languages/databases, for years. They
: all have a logical field type. However, the version of MySQL used by the
ISP
: hosting my site does not support a "logical" field type.
:
: It does support ENUM and I have set some up in a couple of tables that
: accept the values 'T' and 'F'. Sometimes they work like a logical field:
:
: if ($myrow['new']) echo 'New';
: else echo 'NOT new';
:
: and other times I must use:
:
: if ($myrow['new'] == 'T') echo 'New';
: else echo 'NOT New';
:
: I've been searching google and have only come up with some basic info --
: such as use ENUM that allow '0' and '1'.
:
: Before, I go off changing everything, can someone provide some insight in
: using ENUM fields as logical and/or point me to a few good articles/web
: pages?
:
: TIA.
:
: Charles...
:
:
:
:
: ---
: Outgoing mail is certified Virus Free.
: Checked by AVG anti-virus system (http://www.grisoft.com).
: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
:
:
Jul 20 '05 #2
By the way..

Why don't you just:

ENUM('New','NOT New')

and then just echo the value ;)

Wouter
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
: You can try
:
: SELECT (new AND 1) as show FROM yourdatabase
:
: If I'm correct
:
: 0 = first entry
: 1 = second entry
: 2 = 3rd entry
: 3 = 4th entry
: ..
:
:
: If you use SET you can have multiple selected:
:
: 0 = none selected
: 1 = first item selected
: 2 =second item selected
: 3 = first & second item selected
: 4 = 3th item selected
: 5 = 1st + 3rd ..
: 6 = 2nd + 3rd
: 7 = 1st+2nd+3rd .
:
: ...
:
: Maybe this helps.
:
: or you can try:
:
: SELECT (new="New") as show FROM yourdatabase
:
:
: show==0 if not equal
: show==1 if equal
:
::) Hope this helps a bit
: Wouter
:
:
:
: "Charles Crume" <cc@charlescrumesoftware.com> wrote in message
: news:Ui*******************@fe2.columbus.rr.com...
:: Hello all;
::
:: I have used dBASE, and other computer languages/databases, for years.
They
:: all have a logical field type. However, the version of MySQL used by the
: ISP
:: hosting my site does not support a "logical" field type.
::
:: It does support ENUM and I have set some up in a couple of tables that
:: accept the values 'T' and 'F'. Sometimes they work like a logical field:
::
:: if ($myrow['new']) echo 'New';
:: else echo 'NOT new';
::
:: and other times I must use:
::
:: if ($myrow['new'] == 'T') echo 'New';
:: else echo 'NOT New';
::
:: I've been searching google and have only come up with some basic info --
:: such as use ENUM that allow '0' and '1'.
::
:: Before, I go off changing everything, can someone provide some insight in
:: using ENUM fields as logical and/or point me to a few good articles/web
:: pages?
::
:: TIA.
::
:: Charles...
::
::
::
::
:: ---
:: Outgoing mail is certified Virus Free.
:: Checked by AVG anti-virus system (http://www.grisoft.com).
:: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
::
::
:
:
Jul 20 '05 #3
Hi;

Thanks for the reply, but I have no idea what you are talking about. Logical
field can nont have first, second, third, and fourth entries (AFAIK).

Charles...
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
You can try

SELECT (new AND 1) as show FROM yourdatabase

If I'm correct

0 = first entry
1 = second entry
2 = 3rd entry
3 = 4th entry
..
If you use SET you can have multiple selected:

0 = none selected
1 = first item selected
2 =second item selected
3 = first & second item selected
4 = 3th item selected
5 = 1st + 3rd ..
6 = 2nd + 3rd
7 = 1st+2nd+3rd .

...

Maybe this helps.

or you can try:

SELECT (new="New") as show FROM yourdatabase
show==0 if not equal
show==1 if equal

:) Hope this helps a bit
Wouter

"Charles Crume" <cc@charlescrumesoftware.com> wrote in message
news:Ui*******************@fe2.columbus.rr.com...
: Hello all;
:
: I have used dBASE, and other computer languages/databases, for years. They : all have a logical field type. However, the version of MySQL used by the
ISP
: hosting my site does not support a "logical" field type.
:
: It does support ENUM and I have set some up in a couple of tables that
: accept the values 'T' and 'F'. Sometimes they work like a logical field:
:
: if ($myrow['new']) echo 'New';
: else echo 'NOT new';
:
: and other times I must use:
:
: if ($myrow['new'] == 'T') echo 'New';
: else echo 'NOT New';
:
: I've been searching google and have only come up with some basic info --
: such as use ENUM that allow '0' and '1'.
:
: Before, I go off changing everything, can someone provide some insight in : using ENUM fields as logical and/or point me to a few good articles/web
: pages?
:
: TIA.
:
: Charles...
:
:
:
:
: ---
: Outgoing mail is certified Virus Free.
: Checked by AVG anti-virus system (http://www.grisoft.com).
: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
:
:

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
Jul 20 '05 #4
Because I need a standard logical field to use in different situations
besides just "new" and "NOT new" (that was an example).
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
By the way..

Why don't you just:

ENUM('New','NOT New')

and then just echo the value ;)

Wouter
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
: You can try
:
: SELECT (new AND 1) as show FROM yourdatabase
:
: If I'm correct
:
: 0 = first entry
: 1 = second entry
: 2 = 3rd entry
: 3 = 4th entry
: ..
:
:
: If you use SET you can have multiple selected:
:
: 0 = none selected
: 1 = first item selected
: 2 =second item selected
: 3 = first & second item selected
: 4 = 3th item selected
: 5 = 1st + 3rd ..
: 6 = 2nd + 3rd
: 7 = 1st+2nd+3rd .
:
: ...
:
: Maybe this helps.
:
: or you can try:
:
: SELECT (new="New") as show FROM yourdatabase
:
:
: show==0 if not equal
: show==1 if equal
:
::) Hope this helps a bit
: Wouter
:
:
:
: "Charles Crume" <cc@charlescrumesoftware.com> wrote in message
: news:Ui*******************@fe2.columbus.rr.com...
:: Hello all;
::
:: I have used dBASE, and other computer languages/databases, for years.
They
:: all have a logical field type. However, the version of MySQL used by the : ISP
:: hosting my site does not support a "logical" field type.
::
:: It does support ENUM and I have set some up in a couple of tables that
:: accept the values 'T' and 'F'. Sometimes they work like a logical field: ::
:: if ($myrow['new']) echo 'New';
:: else echo 'NOT new';
::
:: and other times I must use:
::
:: if ($myrow['new'] == 'T') echo 'New';
:: else echo 'NOT New';
::
:: I've been searching google and have only come up with some basic info -- :: such as use ENUM that allow '0' and '1'.
::
:: Before, I go off changing everything, can someone provide some insight in :: using ENUM fields as logical and/or point me to a few good articles/web
:: pages?
::
:: TIA.
::
:: Charles...
::
::
::
::
:: ---
:: Outgoing mail is certified Virus Free.
:: Checked by AVG anti-virus system (http://www.grisoft.com).
:: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
::
::
:
:

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
Jul 20 '05 #5
Well..

In MySQL you can have more logical.

For an Multiplpe choise exam:
ENUM('A','B','C','D')
or for en enquette:
ENUM('Yes','No','no opinion')

The first option has logical value 0, the second logical value 1.
The 3rd option has logical value 2, the 4th option logical value 3.

It's not that hard..

It's even handy in some situations.
I normally use:

file_online: 'no','yes','not tested'

with the default value to 'not tested'
In MySQL you can access the value like a logical.
But the result will give you one of the values of the ENUM definition.
I think it's more readble that way than just using 0 and 1 or true and
false.
Vist http://dev.mysql.com/doc/mysql/en/ENUM.html
if it's not yet clear to you.
Wouter
"Charles Crume" <cc@charlescrumesoftware.com> wrote in message
news:yq*******************@fe2.columbus.rr.com...
: Hi;
:
: Thanks for the reply, but I have no idea what you are talking about.
Logical
: field can nont have first, second, third, and fourth entries (AFAIK).
:
: Charles...
:
:
: "Wouter" <no******************@djwice.com> wrote in message
: news:cm**********@news.tudelft.nl...
: > You can try
: >
: > SELECT (new AND 1) as show FROM yourdatabase
: >
: > If I'm correct
: >
: > 0 = first entry
: > 1 = second entry
: > 2 = 3rd entry
: > 3 = 4th entry
: > ..
: >
: >
: > If you use SET you can have multiple selected:
: >
: > 0 = none selected
: > 1 = first item selected
: > 2 =second item selected
: > 3 = first & second item selected
: > 4 = 3th item selected
: > 5 = 1st + 3rd ..
: > 6 = 2nd + 3rd
: > 7 = 1st+2nd+3rd .
: >
: > ...
: >
: > Maybe this helps.
: >
: > or you can try:
: >
: > SELECT (new="New") as show FROM yourdatabase
: >
: >
: > show==0 if not equal
: > show==1 if equal
: >
: > :) Hope this helps a bit
: > Wouter
: >
: >
: >
: > "Charles Crume" <cc@charlescrumesoftware.com> wrote in message
: > news:Ui*******************@fe2.columbus.rr.com...
: > : Hello all;
: > :
: > : I have used dBASE, and other computer languages/databases, for years.
: They
: > : all have a logical field type. However, the version of MySQL used by
the
: > ISP
: > : hosting my site does not support a "logical" field type.
: > :
: > : It does support ENUM and I have set some up in a couple of tables that
: > : accept the values 'T' and 'F'. Sometimes they work like a logical
field:
: > :
: > : if ($myrow['new']) echo 'New';
: > : else echo 'NOT new';
: > :
: > : and other times I must use:
: > :
: > : if ($myrow['new'] == 'T') echo 'New';
: > : else echo 'NOT New';
: > :
: > : I've been searching google and have only come up with some basic
info --
: > : such as use ENUM that allow '0' and '1'.
: > :
: > : Before, I go off changing everything, can someone provide some insight
: in
: > : using ENUM fields as logical and/or point me to a few good
articles/web
: > : pages?
: > :
: > : TIA.
: > :
: > : Charles...
: > :
: > :
: > :
: > :
: > : ---
: > : Outgoing mail is certified Virus Free.
: > : Checked by AVG anti-virus system (http://www.grisoft.com).
: > : Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
: > :
: > :
: >
: >
:
:
: ---
: Outgoing mail is certified Virus Free.
: Checked by AVG anti-virus system (http://www.grisoft.com).
: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
:
:
Jul 20 '05 #6
Sorry I made a mistake.

The first value is 1.
'' = 0

:)
Wouter
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
: Well..
:
: In MySQL you can have more logical.
:
: For an Multiplpe choise exam:
: ENUM('A','B','C','D')
: or for en enquette:
: ENUM('Yes','No','no opinion')
:
: The first option has logical value 0, the second logical value 1.
: The 3rd option has logical value 2, the 4th option logical value 3.
:
: It's not that hard..
:
: It's even handy in some situations.
: I normally use:
:
: file_online: 'no','yes','not tested'
:
: with the default value to 'not tested'
:
:
: In MySQL you can access the value like a logical.
: But the result will give you one of the values of the ENUM definition.
:
:
: I think it's more readble that way than just using 0 and 1 or true and
: false.
: Vist http://dev.mysql.com/doc/mysql/en/ENUM.html
: if it's not yet clear to you.
:
:
: Wouter
:
:
: "Charles Crume" <cc@charlescrumesoftware.com> wrote in message
: news:yq*******************@fe2.columbus.rr.com...
:: Hi;
::
:: Thanks for the reply, but I have no idea what you are talking about.
: Logical
:: field can nont have first, second, third, and fourth entries (AFAIK).
::
:: Charles...
::
::
:: "Wouter" <no******************@djwice.com> wrote in message
:: news:cm**********@news.tudelft.nl...
:: > You can try
:: >
:: > SELECT (new AND 1) as show FROM yourdatabase
:: >
:: > If I'm correct
:: >
:: > 0 = first entry
:: > 1 = second entry
:: > 2 = 3rd entry
:: > 3 = 4th entry
:: > ..
:: >
:: >
:: > If you use SET you can have multiple selected:
:: >
:: > 0 = none selected
:: > 1 = first item selected
:: > 2 =second item selected
:: > 3 = first & second item selected
:: > 4 = 3th item selected
:: > 5 = 1st + 3rd ..
:: > 6 = 2nd + 3rd
:: > 7 = 1st+2nd+3rd .
:: >
:: > ...
:: >
:: > Maybe this helps.
:: >
:: > or you can try:
:: >
:: > SELECT (new="New") as show FROM yourdatabase
:: >
:: >
:: > show==0 if not equal
:: > show==1 if equal
:: >
:: > :) Hope this helps a bit
:: > Wouter
:: >
:: >
:: >
:: > "Charles Crume" <cc@charlescrumesoftware.com> wrote in message
:: > news:Ui*******************@fe2.columbus.rr.com...
:: > : Hello all;
:: > :
:: > : I have used dBASE, and other computer languages/databases, for years.
:: They
:: > : all have a logical field type. However, the version of MySQL used by
: the
:: > ISP
:: > : hosting my site does not support a "logical" field type.
:: > :
:: > : It does support ENUM and I have set some up in a couple of tables
that
:: > : accept the values 'T' and 'F'. Sometimes they work like a logical
: field:
:: > :
:: > : if ($myrow['new']) echo 'New';
:: > : else echo 'NOT new';
:: > :
:: > : and other times I must use:
:: > :
:: > : if ($myrow['new'] == 'T') echo 'New';
:: > : else echo 'NOT New';
:: > :
:: > : I've been searching google and have only come up with some basic
: info --
:: > : such as use ENUM that allow '0' and '1'.
:: > :
:: > : Before, I go off changing everything, can someone provide some
insight
:: in
:: > : using ENUM fields as logical and/or point me to a few good
: articles/web
:: > : pages?
:: > :
:: > : TIA.
:: > :
:: > : Charles...
:: > :
:: > :
:: > :
:: > :
:: > : ---
:: > : Outgoing mail is certified Virus Free.
:: > : Checked by AVG anti-virus system (http://www.grisoft.com).
:: > : Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
:: > :
:: > :
:: >
:: >
::
::
:: ---
:: Outgoing mail is certified Virus Free.
:: Checked by AVG anti-virus system (http://www.grisoft.com).
:: Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
::
::
:
:
Jul 20 '05 #7
HI Wouter;
"Wouter" <no******************@djwice.com> wrote in message
news:cm**********@news.tudelft.nl...
Well..

In MySQL you can have more logical.
Very interesting -- I've never come across this before in any of the
programming languages I've used.

For an Multiplpe choise exam:
ENUM('A','B','C','D')
or for en enquette:
ENUM('Yes','No','no opinion')

The first option has logical value 0, the second logical value 1.
The 3rd option has logical value 2, the 4th option logical value 3.

It's not that hard..
Well, I'm sure having difficulty understanding "the 3rd option has logical
value 2, the 4th...". Logicals have always been 0/1, T/F, on/off for me.
Maybe the light will come on after working on this a little longer.

It's even handy in some situations.
Even though I'm having difficuly grasping the concept, I can easily see this
(not sure why, guess it's just my gut instinct after years and years of
programming).

I normally use:

file_online: 'no','yes','not tested'

with the default value to 'not tested'
I understand this -- in Visual dBASE 'not-tested' would essentially be null
(a value has never been set).

In MySQL you can access the value like a logical.
But the result will give you one of the values of the ENUM definition.
I think it's more readble that way than just using 0 and 1 or true and
false.
Vist http://dev.mysql.com/doc/mysql/en/ENUM.html
if it's not yet clear to you.


I'm going to re-read this.

Thanks again.

Charles...

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 10/29/04
Jul 20 '05 #8

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

Similar topics

3
6964
by: Pjotr Wedersteers | last post by:
Hi I am not even sure if it is at all possible, and I can't find the stuff I am looking for, probably using the wrong search keys. WAMP machine (XP, 2.50.2, 4.1.5, 5.0.2) I have a field in...
3
2369
by: new_GUY | last post by:
I have a HUGE project (at least for me) and need some guidance. I am trying to create a database for a local university movie club that allows users to input there basic personal information...
0
1407
by: Dan McCoy | last post by:
I'm new to MYSQL, having just finished my website. I have 1 thing left to try and do to make the site experiance as seemless as possable, but to do it I figure I need to do some sort of mysql...
2
3067
by: mrhicks | last post by:
Hello all, I have a question about enumerations. Within some requirements data passed back a certain bit field is defined by three bits then in another section the bit field is defined as 4...
31
3563
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
15
4564
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
12248
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
3
2183
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
1
1267
by: Dogandpony | last post by:
Our local club has about 15 Board members, and we vote online using a mySQL/php web interface. I have several different queries/results that I print which show varying displays of...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7274
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,...
1
6984
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
7453
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...
1
5005
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...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.