zoukankan      html  css  js  c++  java
  • mysql 插多行数据

    应用场景:

      需要把一个表(tableA)的个别字段筛选出来,添加到新表中(tableB)。新表还含有其他字段,主键是uuid。

    思路解析:

      熟悉插入一行数据的sql语句:

    insert into customer_healthinfo(PersonalInfoID, CustomerID, ProjectType)
    values(REPLACE(UUID(),"-",""),'110104198002204481','20140201')

      如果数据量极少:

    insert into customer_healthinfo(PersonalInfoID, CustomerID, ProjectType)
    values(REPLACE(UUID(),"-",""),'110104198002204481','20140201'),
    values(REPLACE(UUID(),"-",""),'110104198002204481','20140201'),
    values(REPLACE(UUID(),"-",""),'110104198002204481','20140201')

      数据量大的时候,尝试添加一个中间表,类似于:

    insert into customer_healthinfo(PersonalInfoID, CustomerID, ProjectType)
    select PersonalInfoID, CustomerID, ProjectType from temp_C
    

     sql语句具体实施:

      1.先创建一个新表(table_C,也可以是临时表),存放table_A筛选出来的数据以及一个空字段ID用于存放UUID。

      2.table_C修改ID字段内容为UUID:

    update table_C set id = REPLACE(UUID(),"-","")
    

       3.等同于一个表导入到另一个表的简单问题:

    insert into customer_healthinfo(PersonalInfoID, CustomerID, ProjectType)
    select PersonalInfoID, CustomerID, ProjectType from temp_C
    
  • 相关阅读:
    insertAfter()
    Unity3D之协程(Coroutines & Yield )
    C#中 As 和强制转换的总结
    Mesh系列文章
    在Unity3D 4中关联Visual Studio 2012来编写C#
    Unity3D安装多版本
    Time.deltaTime 增量时间
    Unity3D中Update和Lateupdate的区别
    Making raycast ignore multiple layers
    Unity3d中SendMessage 用法简单笔记
  • 原文地址:https://www.cnblogs.com/gaara-zhang/p/10648888.html
Copyright © 2011-2022 走看看