Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:55:16+00:00 2026-05-25T17:55:16+00:00

I am creating a MySQL Table, and one of column’s type is ENUM .

  • 0

I am creating a MySQL Table, and one of column’s type is ENUM.

I have several different ENUM values. Some of them are two or more words, e.g. Hugo Boss.

Other ENUM values have an apostrophe in them, e.g. Men’s, or other characters, e.g. &.

My question is two part:

  1. It is ok to have one or more spaces in an ENUM value (two words, or more)?
  2. Are apostrophes, ampersands, and other such characters, allowed in ENUM values? And if they are, how would I go about placing them?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:55:16+00:00Added an answer on May 25, 2026 at 5:55 pm

    Seems so:

    MySQL [files]> create temporary table t(foo ENUM('123', '1&2', '3\'4'));
    Query OK, 0 rows affected (0.17 sec)
    
    MySQL [files]> show create table t\G
    *************************** 1. row ***************************
           Table: t
    Create Table: CREATE TEMPORARY TABLE `t` (
      `foo` enum('123','1&2','3''4') COLLATE utf8_unicode_ci DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
    1 row in set (0.09 sec)
    
    MySQL [files]> insert into t values (0), (1), (2), (3);
    Query OK, 4 rows affected, 1 warning (0.12 sec)
    Records: 4  Duplicates: 0  Warnings: 1
    
    MySQL [files]> show warnings;
    +---------+------+------------------------------------------+
    | Level   | Code | Message                                  |
    +---------+------+------------------------------------------+
    | Warning | 1265 | Data truncated for column 'foo' at row 1 |
    +---------+------+------------------------------------------+
    1 row in set (0.11 sec)
    
    MySQL [files]> select * from t;
    +------+
    | foo  |
    +------+
    |      |
    | 123  |
    | 1&2  |
    | 3'4  |
    +------+
    4 rows in set (0.09 sec)
    
    MySQL [files]>
    

    Note: The warning means that I have used a value which was not allowed – I tried to insert 3, which is not defined as value for the ENUM.

    So it works perfectly – as with any other strings in MySQL. You only have to take care that you treat them correctly – either as hex values, or use mysql_real_escape_string() or prepared statements. This provides for correct communication of “critical” values such as \\, ', " etc.

    For example, if I have a string which contains “3’4”, and I want to define it as a part of an enum, I create the query by putting one of 0x332734 or '3\'4' to the appropriate place. '3\'4' is obtained as a result of mysql_real_escape_string("3'4") in the used programming language.

    NUL characters are not allowed as ENUM components as they would be in data strings – the used string is terminated before, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one big table (with tabular data) queried from a MySQL table. Every
So i have MySql and i have a table user with a user_id column
I'm creating a new DB and I have this problem: I have two type
I have a table with several hundred million rows. One of the columns is
I'm creating a Web interface for a table in Mysql and want to use
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have two already-existing tables which look (in part) roughly like this: CREATE TABLE
I'm creating some form to filter my users, table User and I'm discovering the
I've a massive problem creating a view in mySQL: Table A in database DB1:
I have a simple admin I'm creating for a client using PHP and Mysql.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.