
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can I get enum possible values in a MySQL database?
We can achieve possible enum value with the help of ‘enum’. The following is the syntax.
yourColumnName ENUM(value1,value2,........................N)
Let us first create a table.
mysql> create table EnumDemo -> ( -> Light int, -> IsONOrOff ENUM('ON','OFF') -> ); Query OK, 0 rows affected (1.06 sec)
In the above table, ENUM is used to get the possible value for “Light”.
Inserting records.
mysql> insert into EnumDemo values(1,'ON'),(0,'OFF'); Query OK, 2 rows affected (0.24 sec) Records: 2 Duplicates: 0 Warnings: 0
To display all the records −
mysql> select *from EnumDemo;
Here is the output. The ENUM values are visible.
+-------+-----------+ | Light | IsONOrOff | +-------+-----------+ | 1 | ON | | 0 | OFF | +-------+-----------+ 2 rows in set (0.07 sec)
- Related Articles
- How can I get enum possible values in a MySQL database using PHP?
- How can I remove a value from an enum in MySQL?
- How can I get maximum and minimum values in a single MySQL query?
- How can I insert default value in MySQL ENUM data type?
- How can I create a MySQL table with a column with only 3 possible given values?
- How Are MySQL ENUM values sorted?
- Do MySQL Can Enum type values contain spaces in it?
- How to get the possible values for SET field in MySQL?
- Can I get the count of repeated values in a column with MySQL?
- How can I count unique records from a column in MySQL database?
- How can I replace & with an ampersand in my MySQL database?
- How can I update the boolean values in MySQL?
- How can I set a MySQL database to use MyISAM by default?
- Can we get total number of rows in a MySQL database?
- Set ENUM in MySQL for column values

Advertisements