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)
Updated on: 2019-12-26T06:22:14+05:30

478 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements