如何在一个 MySQL 查询中向某列添加用户定义值?
首先创建一个表 -
mysql> create table DemoTable1847 ( GameStatus ENUM('PENDING','COMPLETED','CANCELLED') ); Query OK, 0 rows affected (0.00 sec)
使用 insert 命令在表中插入一些记录 -
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)
使用 select 语句显示表中的所有记录 -
mysql> select * from DemoTable1847;
这会产出以下输出 -
+------------+ | GameStatus | +------------+ | PENDING | | COMPLETED | | CANCELLED | +------------+ 3 rows in set (0.00 sec)
以下是向 MySQL 查询中的某列添加用户定义值的查询
mysql> select * from DemoTable1847 union all select 'REFUND';
这会产出以下输出 -
+------------+ | GameStatus | +------------+ | PENDING | | COMPLETED | | CANCELLED | | REFUND | +------------+ 4 rows in set (0.00 sec)
广告