码迷,mamicode.com
首页 > 数据库 > 详细

mysql表与表之间数据的转移

时间:2018-12-06 20:38:56      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:tps   where   声明   ber   HERE   数据   art   参考   amp   

1.相同表结构

INSERT INTO table1 SELECT * FROM table2;

2.不同表结构

INSERT INTO table1(filed1,...,filedn) SELECT table2.filed1,...,table2.filedn FROM table2;

3.如果是不同数据库之间,参考以下:

INSERT into db_ds_edu.t_exam_student(stu_id,stu_number,stu_name,school_id,campus_id,grade_id,class_id,xuebu_id) 
  SELECT stu.id 
     , stu.student_num 
    ,person.name 
     , stu.school_id 
     , stu.campus_id 
     , stu.grade_id 
     , stu.clas_id 
     , stu.xuebu_id 
FROM 
  db_ds.t_stu_info AS stu 
    ,db_ds.t_p_person_info as person 
    WHERE stu.person_id = person.id 
---------------------
作者:清无时空
来源:CSDN
原文:https://blog.csdn.net/sinat_34439107/article/details/70214335
版权声明:本文为博主原创文章,转载请附上博文链接!

mysql表与表之间数据的转移

标签:tps   where   声明   ber   HERE   数据   art   参考   amp   

原文地址:https://www.cnblogs.com/wtsgtc/p/10078015.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!