db2 sql批量插入一張表插入另一張表

Waiting!!發表於2020-12-24

INSERT INTO EQU.T_EQ_PERSONTEAM(EQ_PERSONTEAMID, FACTORYID,org_ID,PERSON_ID,TEAMID,POSTTYPE,POSTID,ISVALID,remark,LASTOPERATOR,LASTOPERATETIME) 
(SELECT 
lower(sys_guid()) EQ_PERSONTEAMID,
0 FACTORYID,
person.AREAID org_ID,
person.ID PERSON_ID,
0 TEAMID,
post.POSTTYPE POSTTYPE,
person.postid postid,
person.isused ISVALID,
'' remark
FROM pub.PERSON person
LEFT JOIN PUB.POST post  ON person.POSTID=POST.ID
WHERE  person.ID NOT IN (SELECT PERSON_ID FROM EQU.T_EQ_PERSONTEAM))
 

相關文章