
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add User Defined Value to a Column in MySQL Query
Let us first create a table −
mysql> create table DemoTable1847 ( GameStatus ENUM('PENDING','COMPLETED','CANCELLED') ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1847 values('PENDING'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('COMPLETED'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1847 values('CANCELLED'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1847;
This will produce the following output −
+------------+ | GameStatus | +------------+ | PENDING | | COMPLETED | | CANCELLED | +------------+ 3 rows in set (0.00 sec)
Here is the query to add user defined value to a column in a MySQL query
mysql> select * from DemoTable1847 union all select 'REFUND';
This will produce the following output −
+------------+ | GameStatus | +------------+ | PENDING | | COMPLETED | | CANCELLED | | REFUND | +------------+ 4 rows in set (0.00 sec)
Advertisements