查询并批量插入数据的Sql命令

INSERT INTO student(id,xuesheng,yuwen,shuxue,yingyu)
SELECT id,xuesheng,yuwen,shuxue,yingyu FROM stu;

实践:
insert into store_advertisings(id,title,PicListJson,edittime)
(select s.Id,s.`Name` as name , '[]',NOW() from stores s left join store_advertisings d on s.Id= d.Id where d.Id is null)

 

实践

insert deyouyun_notices_local.deyouyun_sms_statistics(id, IdentificationCode, StoreId,RemainSmsCount, SendSuccessCount, UpdateTime, CreateTime,SendChargeSuccessCount) (select uuid(), s.IdentificationCode, s.Id, 200, 0, NOW(), NOW(), 0 from deyouyun_store_dev_local.deyouyun_stores s left JOIN deyouyun_notices_local.deyouyun_sms_statistics st
on s.Id = st.StoreId where st.StoreId is null)

 

posted @ 2019-12-18 14:16  向萧  阅读(2281)  评论(0编辑  收藏  举报