View Full Version : how to insert values into enum fields in mysql

05-07-2007, 07:59 AM
hi to all,

i want to insert data into enum fields but i am not able to insert values. can any one help me regarding this


05-07-2007, 08:08 AM
whats an enum field?

05-07-2007, 08:16 AM
I'm not sure of the specifics of enum, but it's a certain type of field.
INSERT INTO `field`.... would be the query, like any other field.
However, it may relate to the specific type of data it can support, so you will need to check the length and type of data to be sure it's supported.

05-07-2007, 08:18 AM
it is a datatype in mysql

05-07-2007, 11:03 AM
i want to insert data into enum fields but i am not able to insert values. can any one help me regarding this

There is nothing special about updating enum columns beyond what's mentioned in the MySQL manual.

For example, given the definition:

  ENUM('a', 'b', 'c')

for a column named enum, the query:

  INSERT INTO table (`enum`) VALUES ('a')

will add the value 'a'. Using a number will index the enumeration:

  INSERT INTO table (`enum`) VALUES (3)

The query above will add the value 'c'.


02-15-2008, 07:46 AM
I recently have been looking into this.
Depending on how the column is setup.
Will determine if you can just enter data into the column itself.
If it is a enum list that is within the design of the table column attributes.
And that syntax will not work.
That is the exact problem i am trying to solve at the moment.
Seems phpmyadmin will allow a alter statement of the enum attributes but will not allow direct data entry into the row.
As a enum column is a list it needs to be altered at the design state not just normal data entry.
Wish i could find a proper syntax for this.

02-15-2008, 11:43 AM
You mean to say you're trying to update the possible values of the enum field with a query? That's an abuse of enum, don't do it. If you're going to be creating your own values, just use a text field of some kind.

09-18-2011, 06:56 AM
Thank you very much MWinter Sir, i have been searching the solution to this query from more than 2 weeks. i have 10 such enum fields. and now my project is working fine