Add user defined value to a column in a MySQL query?

MySQLMySQLi Database

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)
raja
Published on 26-Dec-2019 10:52:14
Advertisements