Results 1 to 8 of 8

Thread: how to insert values into enum fields in mysql

  1. #1
    Join Date
    Apr 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to insert values into enum fields in mysql

    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

    regards
    Last edited by janunme; 05-07-2007 at 08:20 AM.

  2. #2
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    whats an enum field?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Apr 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it is a datatype in mysql

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by janunme View Post
    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:

    &#160;&#160;ENUM('a', 'b', 'c')

    for a column named enum, the query:

    &#160;&#160;INSERT INTO table (`enum`) VALUES ('a')

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

    &#160;&#160;INSERT INTO table (`enum`) VALUES (3)

    The query above will add the value 'c'.

    Mike

  6. #6
    Join Date
    Feb 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •