- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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)
- Related Articles
- Updating a MySQL table row column by appending a value from user defined variable?
- MySQL SELECT to add a new column to a query and give it a value?
- MySQL query to replace a column value
- MongoDB query to set user defined variable into query?
- How to display grant defined for a MySQL user?
- How to add column and index in a single MySQL query?
- Add a temporary column with a value in MySQL?
- How can I return a record from a table nearest to a user-defined variables value in MySQL?
- Select into a user-defined variable with MySQL
- In MySQL, why a client cannot use a user-defined variable defined by another client?
- How can we store a value in user-defined variable?
- MySQL query to remove a value with only numbers in a column
- Using User-Defined Variables in MySQL
- How to add a column from a select query but the value from the new column will be the row count of the MySQL select query?
- Add a new value to a column of data type enum in MySQL?

Advertisements