使用现有的表数据创建新的表调用Admin

时间:2019-01-15 08:00:37

标签: mysql

我想用现有的表数据创建新的表调用Admin。

Employee table
+--------+---------+----------+-----+
| emp_Id.  | surname. |  fist_name | staff |  
+--------+---------+-----------+----+
|   100.     |     JOE.     |   ADEX.   | admin 
|    102.    |   JHON.    |   LEO.     | admin
|     103.   |    OLA.     | BABS.   |  admin. |
+--------+---------+--------+-------+


CREATE TABLE `admin` (`username` TEXT,`password` TEXT);
INSERT  INTO  `admin`(`username`, `password`)
VALUES  FROM `employee` `emp_id` =`admin. username` AND `surname` = `admin.password` ;

1 个答案:

答案 0 :(得分:0)

您可以使用基于选择的创建

Create table `admin` 
select   `emp_id`,  `surname` 
from `employee`