MySql教程

mysql获取一张表中部分字段,再批量导入新表中

本文主要是介绍mysql获取一张表中部分字段,再批量导入新表中,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
insert into  testersPage (testersId ,id,status) 
             select id as  testersId , CONCAT('P',md5(uuid())) as id, 1 as status     
             from  testers   ;

新表: testersPage(测试表页面)               旧表:testers(测试表)

需求:新表关联旧表

从旧表中获取id:  select id as testersId  from testers ;

生成uuid:  CONCAT('P',md5(uuid()))       32位+1 位('P'开头首字母)

1 as status :作为常量输入

公式: insert into 表名(字段)值

这篇关于mysql获取一张表中部分字段,再批量导入新表中的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!