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"

 

posted @ 2019-01-29 16:03  margot921  阅读(360)  评论(0编辑  收藏  举报