類別一轮洋、如果兩張張表(導(dǎo)出表和目標(biāo)表)的字段一致枉氮,并且希望插入全部數(shù)據(jù)志衍,可以用這種方法:
INSERT INTO? 目標(biāo)表? SELECT? * FROM? 來源表 ;
例如暖庄,要將 articles 表插入到 newArticles 表中,則可以通過如下SQL語句實(shí)現(xiàn):
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