 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 a 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
 