
- 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
Selecting rows using the ENUM field in MySQL
Let us first create a table −
mysql> create table DemoTable -> ( -> EmployeeStatus ENUM('FULLTIME','Intern') default NULL -> ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('FULLTIME'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Intern'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Intern'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+----------------+ | EmployeeStatus | +----------------+ | FULLTIME | | Intern | | Intern | | NULL | +----------------+ 4 rows in set (0.00 sec)
Here is the query to select rows using the ENUM field in MySQL −
mysql> select * from DemoTable -> where EmployeeStatus is null or EmployeeStatus <> 'Intern';
This will produce the following output−
+----------------+ | EmployeeStatus | +----------------+ | FULLTIME | | NULL | +----------------+ 2 rows in set (0.00 sec)
- Related Articles
- Enum with NOT NULL in a MySQL field?
- MySQL: selecting rows where a column is null?
- Selecting rows that are older than current date in MySQL?
- Selecting cut field value of SAP tables using JCo
- Create a MySQL table from already created table selecting specific rows?
- Selecting and displaying only some rows from a column in a MySQL table
- Selecting only a single field from MongoDB?
- Error while selecting into field-symbol in SAP ABAP
- MySQL query to group rows by the numeric characters in a string field?
- Selecting all the users with maximum age values using a MySQL subquery?
- Selecting a single row in MySQL?
- Display multiple selected rows using MySQL IN()
- How to count all characters in all rows of a field in MySQL?
- Selecting Random Result from MySQL?
- Fetch rows where a field value is less than 5 chars in MySQL?

Advertisements