批量新增查询到的结果集 INSERT INTO SELECT

基本语法:
INSERT INTO "表格1" ("栏位1", "栏位2", ...)
SELECT "栏位3", "栏位4", ...
FROM "表格2"


db是mysql,由于id是auto_increment的实例:
inset into t_split_aa(batchId,contractId,clientId,type,year,month,date,amount,totalPrice,totalHours,unitPrice,note,days,signDate,cancelDate,firstDate,legalId,freezenDays)
select batchId,contractId,clientId,type,year,month,date,amount,totalPrice,totalHours,unitPrice,note,days,signDate,cancelDate,firstDate,legalId,freezenDays from t_split_a order by id 

你可能感兴趣的:(sql,mysql)