• SQL--迁移条件数据和补全数据数值


    目的:我要把老顾客的部分数据迁移到另一个表里面

    -- 步骤一:筛选查询
    --  打开表,只显示想要看到的数据列
    --  做条件筛选,筛选出想要的数据
    -- 步骤二:sql查询 SELECT ID,Name,Gender,Mobile,CreateTime FROM smartcustomer WHERE ID <=100010 AND ID >100005
    -- 步骤三:迁移数据
    INSERT INTO smartwxpromoter
    (customerID,name,gender,mobile)
    (
    SELECT
    ID,name,gender,mobile
    FROM
    smartcustomer
    WHERE
    smartcustomer.ID<=100010 AND
    smartcustomer.ID>100005 
    )
    -- 步骤四:设置数据
    UPDATE smartwxpromoter
    -- SET (A1,B1,C1)=(A2,B2,C2),这个语法MS SQL Server不支持(oracle和DB2支持)
    SET
    CreateTime=now(),
    AppID="wx2cda971ec714f9fe",
    BlacklistType=0
    -- 步骤五:删除测试数据
    DELETE 
    FROM smartwxpromoter
    WHERE
    CreateTime="2019-01-29 12:01:00"
  • 相关阅读:
    WebGL_0008:支持移动端的控制台调试工具
    调整两数组元素使得两数组差值最小
    集五福
    打印机顺序打印
    子弹分发
    字符串分割
    乐观锁、悲观锁
    字符串去重
    数组最后剩下的数字
    shell常用工具
  • 原文地址:https://www.cnblogs.com/margot921/p/10334516.html
Copyright © 2020-2023  润新知