让我们首先创建一个表-
mysql> create table DemoTable1 ( Name varchar(100), Gender ENUM('MALE','FEMALE') );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1 values('Chris','Male'); mysql> insert into DemoTable1 values('Emma','Female');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable1;
这将产生以下输出-
+-------+--------+ | Name | Gender | +-------+--------+ | Chris | MALE | | Emma | FEMALE | +-------+--------+ 2 rows in set (0.00 sec)
以下是创建第二个表的查询-
mysql> create table DemoTable2 ( EmployeeGender varchar(100) );
现在让我们使用一个MySQL查询将一列的值复制到另一列-
mysql> insert into DemoTable2(EmployeeGender) select Gender from DemoTable1; Records: 2 Duplicates: 0 Warnings: 0
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+----------------+ | EmployeeGender | +----------------+ | MALE | | FEMALE | +----------------+ 2 rows in set (0.00 sec)