Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Enum Types


I would like to know if it is possible and how to have an extra box on your webpage so, if in your enum field the type that the person wants is not there then they write it in the next field. When they click submit it is automatically updated so next time someone comes a long they can click the drop down list and select that one. Also is there anywhere you can get pre made enum lists for country, county etc.....




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Data Types :: Blob And Text Returns Only Value 252 $handle->types
I'm writing a perl script that will among other things collect data types from a mysql database. I'm using mysql.pm 2.9002 to retrieved types information from the statement handle.

The problem is that all blob and text fields return the value 252 when using the $handle->types function and I need to differentiate between them. Has anyone else dealt with this issue?

View Replies !   View Related
Enum
If you have an enum field, is it possible to get a list of all the values?

View Replies !   View Related
Using Enum
I want to use an Enum column to indicate which unit and section a plan belongs to.

For example my Enum column unit will be "Teaching and Learner Support", "Assessment Credits and Awards". My Enum column section will be "Planning and Finance", "Quality and Review".

I uderstand that if I have a dropdown with values 1,2,3, these will be converted into the correct database Enum values when submitted. Eg this will enter the correct information in the database.

HTML
<select name="unit">
<option >-- Select unit --</option>
<option value="1">Teaching and Learner Support</option>
<option value="2">Assessment Credits and Awards</option>
</select>
However when pulling info out of the database for viewing and editing how do I get both the Enum literal string value and the numeric value to reproduce the above code.

View Replies !   View Related
Why Not Use ENUM?
I have seen quite a lot of posts about people saying not to use MySQL's ENUM data type, but I have not been able to find a reason for this. Can anyone explain to me the problems with using ENUM, or possibly link me to an article?

View Replies !   View Related
Enum Set Null Value
I am using mysql db.The table structure is given below ....

View Replies !   View Related
ENUM Type
I have a ENUM attribute in a table. I wish to Count the number of records for each paticular type in the attribute.
Doing a SELECT COUNT(*) from 'my_table'
GROUP BY 'enum_attribute'
returns me the number of records for each particular enum.

How do I get this to list each enum type next to the count:
i.e.
column1 column2
Enum1 237
Enum2 232
Enum3 2
etc.

To clarify, I have column2, I need to know how to get column1.

View Replies !   View Related
Dynamic Enum
Is there a way for me to have an enum field with values based on records in another table? So if a record is added to that table the possible enum values change too.

View Replies !   View Related
ENUM And Php Admin
Creating database in mysql using php admin, if I pick the datatype Enum and the if I have values for enum 'view' and 'url'
. Where do i put these values. I mean would it be in Length/Values colum or attributes?

View Replies !   View Related
Enum Or Indexes
My question is, would there be a significant impact on optimization by removing the enum in favor of other tables.For example, in the table there is a column of type enum to represent the 50 states. Is there any advantage performance-wise to move these 50 states into a table?

View Replies !   View Related
ENUM Support
i've heard that ENUM is not MySQL standard and we should avoid to use it.
there's nothing about that point in MySQL manual and i think if it's supported, why not to use it?

View Replies !   View Related
ENUM Values
Is there a way to get values for an ENUM field from another table in the database? What is the SQL syntax for that.In other words, I have a table called "products" which has a field called "category". The field category should be an ENUM composed only of values stored in the category table. Basically, can we use a SELECT statement within an ENUM description?

View Replies !   View Related
ENUM Field
if i give index to the enum field with two values ,is there any use for it...? in one forum one suggested me there is no need of index, if so what will happen if i search the records using one enum field
it will be fast even with out an index
out of my 1 million records 90% records will have one value (may be '1')and remaining will be have another(may be '0').

View Replies !   View Related
Ndex An ENUM
I've got an ENUM field in a table which is going to store three strings.
These strings will not be changing.
But I also know that it will be used a LOT in the WHERE clause of my queries.

1. Is it necessary to add a column index on an ENUM field?
2. Is it good or bad to add a column index on an ENUM field?
3. Will it speed things up?
4. Will it slow things down?

View Replies !   View Related
Enum From Other Table
I´m trying to to put items on an Enum type from a table with those items, and in the case I add items to that table reflects in the enum column type of the other table.

for example,

Table city:
id_city city
1 bogota
2 buenos aires
3 barcelona

how can I put those cities in an enum type in other table automaticaly??.

Table customer:
id_customer name city
1 jhon enum type?????

View Replies !   View Related
Add A Value To An Enum Field
How do I add a value to a field that is an enum field?

enum('','CODE CHANGE','NOT A BUG','UNABLE TO RECREATE','HOLD - FIX IN LATER VERSION','DUPLICATE','MOVED')

I would like to add 'DOCUMENTED' to this field.

View Replies !   View Related
Strict ENUM
I would like to strictly limit the value in a particular ENUM column to the EXACT values in the ENUM (in this case: YES and NO):

CREATE TABLE `enum_test` (
`id` int(10) default NULL,
`value` enum('YES','NO') NOT NULL default 'YES'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

mysql> INSERT INTO enum_test(id, value) VALUES (1, 'YES');
Query OK, 1 row affected (0.03 sec)

mysql> SELECT * FROM enum_test;
+------+-------+
| id | value |
+------+-------+
| 1 | YES |
+------+-------+
1 row in set (0.00 sec)

mysql> INSERT INTO enum_test(id, value) VALUES (2, 'NO');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM enum_test;
+------+-------+
| id | value |
+------+-------+
| 1 | YES |
| 2 | NO |
+------+-------+
2 rows in set (0.00 sec)

mysql> INSERT INTO enum_test(id, value) VALUES (3, NULL);
ERROR 1048 (23000): Column 'value' cannot be null
mysql> INSERT INTO enum_test(id, value) VALUES (3, '');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SELECT * FROM enum_test;
+------+-------+
| id | value |
+------+-------+
| 1 | YES |
| 2 | NO |
| 3 | |
+------+-------+
3 rows in set (0.00 sec)

As you can see, '' (empty string) is happily accepted by MySQL. Is there any way to strictly limit this to YES and NO, in this case?

View Replies !   View Related
SET Datatype ENUM
I understood that SET datatype is kind of like ENUM but offers the option of choosing more than value.

The question is, what if I have more than two values: let's say i have a column of colors and the options are: "blue" "red" and "green".

What will the user be avle to choose:
1. blue
2. red
3. green
4. Now what ? all the combinations of 2 of them, or maybe all three of them.

View Replies !   View Related
Enum And Char
for a field to save city name,ENUM and CHAR which is better?(in performance,not care consistent)

View Replies !   View Related
ENUM Cols
Upgraded to 5.0 and cannot SELECT enum_col_type FROM some_table;
mysql reports a syntax error in statement?

View Replies !   View Related
Using Enum In Table
I'm trying to add a new field to an existing table. I would like to add a simple yes/no in the field.

here's what I did:

field: eligible
type: enum
length/values:
attributes:
null: not null
default:
extra:

I'm getting this error: #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL' at line 1

What am I doing wrong?

View Replies !   View Related
INT, ENUM Or CHAR?
I have several fields that are either 1 or 0.
What's the best field type for this? Int, tinyint, enum, char(1)? Some of these may be used while searching.

View Replies !   View Related
Get The Enum Values
how can I get the variable that enum field can take it? like if I have Sex field that could take (male,female) .

I need something like that:

select (all the values for the sex field) ; //output (male,female).

View Replies !   View Related
COUNT() Vs. ENUM
I'm having a problem, which I'm pretty sure is fairly generic, but I can't figure out the solution.

Assume the following table:

create table test (
category varchar(255),
status enum("on", "off")
);
insert into test values ("foo", "on"), ("foo", "off"), ("bar", "on"), ("bar", "on");
I want to select a result, returning category, count of rows, where status = "on", and count of rows, where status = "off", grouped by category. In pseudo-


select category,
count(status="on") as num_on,
count(status="off") as num_off
from test
group by category;
Which should return something like the following:

+----------+--------+---------+
| category | num_on | num_off |
+----------+--------+---------+
| foo | 1 | 1 |
| bar | 2 | 0 |
+----------+--------+---------+

Any suggestions?

View Replies !   View Related
Changing ENUM Values
So I've got fairly big sized table (20,000 records) which has an ENUM row. I need to change the name of one of the ENUM options. For example, if the ENUM value was 'blue' before, it needs to be 'purple' now. What's the best way to do this?

View Replies !   View Related
Enum Setting Using NaviCat
This is what I am doing something wrong with my mySQL NaviCat.
My php says that I have a error " Unknown column 'type' in field list"

Is my Setting for MySQL correct???? ....

View Replies !   View Related
ENUM Constraint Type
With the ENUM constraint type, instead of typing in the list of values in the CREATE TABLE statement can you reference another table for the values? Seems to me it would easier to maintain another table than write ALTER statements all the time. My version is 4.0.26

View Replies !   View Related
Drop-down List -enum
I have a php form that contains several drop down lists, which I want to enter into a MySql database onn submit. The values under each drop down are many, e,g,. in the "which country are you from" drop-down list there are 238 countries.
So, in phpMyAdmin, do I specify the field type as ENUM? If I do, then do I need to enter manually ALL the country names in the field "type" column? ('x','y','z'. etc...). Is there a quicker way to enter the value types into that column? It would take me ages to write every country.

View Replies !   View Related
Inserting ENUM Value Into TABLE? How?
i'm trying to insert an ENUM value into table,
the field column inside a table is also set to ENUm.

$query = "INSERT INTO users (activated)
VALUES (&#391;')";

mysql_query($query) or die('Error, insert query failed');

View Replies !   View Related
Enum Select Default Value
i've got a html form

you can choose values for a field in the form via popup. the popup values are grabbed from an enum type field in a table

i want the default value in the popup in the html form to be equivalent to 'where 1' so if the form is submitted w the default value from the popup, it returns all the db entries

the question is: what do i put into the enum field list to do this ?


View Replies !   View Related
Seperate Categories Vs. Enum
I have a simple CMS and I am wondering what is the correct way to categorize articles in a database. I have a main articles table, like so:

CREATE TABLE articles (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(40) NOT NULL,
description TEXT,
details LONGTEXT,
picture VARCHAR(40),
rating TINYINT(2)
CONSTRAINT id PRIMARY KEY (id)
)
ENGINE=InnoDB;

What i'm wondering is, is it better to have one column in this table called say 'category' with a type of ENUM, and I list all the categories. Or is better to have 2 other tables, one categories and one article categories like so:

CREATE TABLE categories (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(40),
CONSTRAINT PK_categories PRIMARY KEY (id)
)
ENGINE=InnoDB;

CREATE TABLE articles_categories (
article_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
CONSTRAINT PK_articles_categories PRIMARY KEY (article_id, category_id)
)
ENGINE=InnoDB;

ALTER TABLE articles_categories ADD CONSTRAINT articles_articles_categories
FOREIGN KEY (article_id) REFERENCES articles (id) ON DELETE CASCADE;

ALTER TABLE articles_categories ADD CONSTRAINT categories_articles_categories
FOREIGN KEY (category_id) REFERENCES categories (id) ON DELETE CASCADE;

And then when I want to get all articles in say the 'News' category, I could simply just do a join or whatever. If I use the categories column in the articles table, then I don't have to worry about the other tables. I'm not sure which is is 'correct'. If there is such a thing.

View Replies !   View Related
Enum Type, Sort, Restrict, Use
After reading that enum column is very efficient, I'm determined to use
it where I can.
Does anyone have WebApp experiences, that make life easier.

I can see applications for US states, phone types, order types, etc.
but for example
in a contact manager business phone types may differ than personal
phone types
ie:
work
home
cell
247
pager
day
eve

I guess this column type is best used with a mutually exclusive,
defined, stable set of choices, and can be difficult to use otherwise.

View Replies !   View Related
Sort On Column Type Enum
I have a column of type enum('A', 'AP', 'CR', 'D', 'DL', 'H', 'HD',
'HH', 'R', 'S', 'PL'). i want to sort the result by 'DL', 'H','A',and
the rest.

View Replies !   View Related
ENUM (logical) Fields In MySQL
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?

View Replies !   View Related
Renaming Values In Table With ENUM
It seems that this table was created with some ENUM data types so I'm trying to figure out how this works. I can post the script that created this table but basically I'm trying to rename a value in this column document_type ENUM('FAQ', 'Sheet', 'Marketing Resource', 'Teacher Guide', 'Reference / User Guide') NOT NULL,

I'm not sure how this array is stored and what would happen if I tried to rename the value ....

View Replies !   View Related
An Enum Field Using Values From Another Table
The first table, called genus, contains several fields, the important one in genus is name, and there are others about the individual plant types.

The second table 'plants' needs one field for the genus name, so that I can link tables on this. If there a way to make a foreign key from the genus table into an enum field on the second? My idea is that then, with phpmyadmin or similar I can just select the genus name from a list when entering new plant data.

View Replies !   View Related
LOAD DATA INFILE + ENUM
I'm working with MySQL 5.0.45-community-nt MySQL Community Edition (GPL) I have a problem with loading data into a table. The table looks like this:

+--------------+-------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------------------------+------+-----+---------+-------+
| ProductID | varchar(6) | NO | PRI | | |

| Omschrijving | varchar(20) | NO | | | |

| Lengte | tinyint(3) unsigned | NO | | | |

| Breedte | tinyint(3) unsigned | NO | | | |

| Hoogte | tinyint(3) unsigned | NO | | | |

| Type | enum('HEV','ELV','MOT','FIX') | YES | | NULL | |

+--------------+-------------------------------+------+-----+---------+-------+

Does anyone know how I have to format the CSV-File to import data into the table.
When I load data into the table, the column 'Type' is empty.

example of csv-file:
000001;omschrijving1;19;7;7;"4"
000002;omschrijving2;19;8;7;"4"
000003;omschrijving3;19;9;21;"2"
000004;omschrijving4;19;9;7;"4"
000005;omschrijving5;19;7;9;"4"
000006;omschrijving6;19;7;11;"1"

I also tried it without double quotes, with single quotes and with the values ('HEV','ELV','MOT','FIX') of the enum, also with and without double/single quotes

View Replies !   View Related
Join Group By Enum Column?
_table1
id
name

_table2
id
table1_id
color enum('red','blue','yellow')

How can we do a join to get a count from table1 joining table2 based on the color of the item?

Resultset format:

id, name, red_count, blue_count, yellow_count

View Replies !   View Related
ENUM Vs TINYINT, FLOAT Vs DECIMAL
I have a field in my table that stores the type of a content entry. I currently have it set as an ENUM, with the values GAME, MOV, ANIM. This makes it easier to see exactly what that row contains. However, I also use this column in a few WHERE clauses, such as SELECT * FROM content WHERE type = 'GAME'

though it would be more obscure, would it be a better idea to just use a TINYINT and make a number that represents each type? IE 'GAME' = 2. Less storage space, more efficient index, better performance, but a bit more work for me. Will the trade off be truly worth it? This table has roughly 50 rows in it, but is accessed quite frequently. To help, I could create a caching script that writes the content of the table out to a text file and update it every 10 minutes or so, instead of allowing constant db hits

next up, FLOAT vs DECIMAL.
FLOAT is 4 bytes, DOUBLE is 8 bytes, and DECIMAL varies...

I'm storing a 'rating' column for my content. It will be a number between 1-10, but needs to have some decimal places for precise rankings. IE so something can be rated 5.6443 and beat something ranked 5.6441. To allow for this I would need DECIMAL(6,4). 8 bytes of storage. However, I'm on mysql 4.1, which means decimals are stored as strings. A float would use less space and be more efficient because it's not a string (?), but I read that floats are less accurate. I'm just not sure by how much. I just need something able to reliably differentiate between entries.

View Replies !   View Related
MySQL Command To List Enum Values Of A Column? - ALL SET
I'm wondering if there is a MySQL command to list all the enum values of a given column. For example, I have a column defined as:

sgroup enum('none', 'aaaaa', 'bbbbb', 'ccccc') not null
What command can I run to get the list of these possible values?

View Replies !   View Related
ROW TYPES
I'm trying to use the "CREATE ROW TYPE name" feature that SQL has, but it doesn't seem like its supported in MySQL. Does anyone know what I can use to create a cell with multiple fields? Basically a row nested within a row. I am also trying to use the array type like "Phone CHARACTER VARYING (15) ARRAY [5]," when creating a column within a table. I would like to have multiple values (phone numbers) for this column field. This is another feature that I know SQL has but it gives me an error when I try it in MySQL. Do I need a different version of MySQL? I'm using the free 5.0.37 version.

View Replies !   View Related
Column Types
I've just moved out of the access suburbs and into MySQLville. I'm having trouble understanding the column types and when to use which one. Can anyone give me a short rundown in plain english how to understand them.
To point out some areas: the ENUM and SET... when to use them. Which BLOB or TEXT type to use.
To give an idea of what I'm designing: a job board, similar to Monster.com

View Replies !   View Related
Summing With Different Types
I have a table that sort of logs everything. It's structure is basically divided into 3 columns:
date, type, points

I have like 3 different types but I want to output the data as:
date, points_from_type1, points_from_type2, points_from_type3

basically points_from_type1 is the sum of the points accumulated for that day same for type 2 and 3. Is there any way of doing this easily?

The best way I can think of doing this is creating 3 different tables with 3 different queries of "select date, sum(points) from table_1 where type = 1 group by date;" and merging them together.

View Replies !   View Related
Two Types Of Sorting
I have a database which has these colums: id, weith and date f.
I want to select some of my datas but in this way.
If the diffrecence between today and the date that is stored into database is less then 30 days, then it must sort first by weith and after that by date.
If the diffrences is more that 30 days, then it must sort first by date and after that by weith.

View Replies !   View Related
Map JDBC Types
I'm setting up a server-application on a tomcat that is developed for SQL Server or Oracle but I got the thankless task of trying to set up the application on a MySQL instead.
One part of setting up this is to port some properties-files and I cannot get the hang of it.
Is there some friendly soul out there that could give me a hand?
I've included the content of properties-files below for SQL Server and I believe you'll get how it should be ported to MySQL. Most part of the content is the same in all three files but I included them all anyway

View Replies !   View Related
Field Types
I can't seem to find a built in function or view that will return all the available
field types. I know I can piece together a list from the docs, but I don't want to have to do that everytime a new version of Mysql comes out(if possible)

View Replies !   View Related
Col Types For Pricing
I need to create a "product" table. For the column that will hold the price of the product ie; 49.95 - what data type should I use?

View Replies !   View Related
All Types In A Column
I have a column in my table called 'catagories'.

In this column, my rows have different data for this section.

They say: Phosothop, PHP, Flash...etc...

How can i export the column and compare them and take only the unique catagories, and order them in alphabetical A=>Z?

Is there an easier way to do this? It seems like if i do this, with a big table, it could potentially take a while to do.

View Replies !   View Related
Best Data Types
i would very much like to know, what the most efficient/suitable Data Types would be used with the following data:?

Account Details:
Email Address
Password
Email Updates?
Interested Sites (6 Check Boxes Max)

Personal Details:
Title (Mr, Mrs, Miss, Ms, Dr)
First Name
Last Name
Image Title
Upload Image
Address:
Property Name/Number
Street Name
Location
Town/City
Country
Postcode
Telephone
Work
Mobile

View Replies !   View Related
Mixed Table Types
Here's one of those damned annoying "what if" questions for everyone.
If I have a transaction that performs INSERTs or UPDATEs on a bunch of
tables, some InnoDB and some MyISAM, and after performing a bunch of
modifications on each I issue a ROLLBACK, does the fact that a MyISAM
table is involved in the process cause any problems with the ROLLBACK at
all?
Any definitive answer either way would be appreciated, as I have just
inheritted the codebase from hell to either maintain or redo parts

View Replies !   View Related
Switching Indexing Types
I am still a novice when it comes to MySQL and I was wondering if switching
the indexing from INDEX to a FULLTEXT would have any dramatic
repercussions on current searches based on the the INDEX format?

I have 3 indexed fields: unit_id, customer_id, facility_id all in one
table called units. I would like to do text searches unit ids but
also account for user mistakes, like incomplete unit ids and return
all possible matches.
Doing some research on the MySQL site, they have lots of examples
based on FULLTEXT indexed fields.

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved