类别一、如果两张张表(导出表和目标表)的字段一致,并且希望插入全部数据,可以用这种方法:
INSERT INTO 目标表 SELECT * FROM 来源表 ;
例如,要将 articles 表插入到 newArticles 表中,则可以通过如下SQL语句实现:
INSERT INTO newArticles SELECT * FROM articles ;
INSERTINTOTPersonnelChange(
UserId,
DepId,
SubDepId,
PostionType,
AuthorityId,
ChangeDateS,
InsertDate,
UpdateDate,
SakuseiSyaId
)SELECT
UserId,
DepId,
SubDepId,
PostionType,
AuthorityId,
DATE_FORMAT(EmployDate,'%Y%m%d'),
NOW(),
NOW(),
1
FROM
TUserMstWHERE
`Status`=0
ANDQuitFlg =0
ANDUserId >2