

update security_person t1,security_company_person t2
set t2.entryDate = t1.entrydate
where t1.id =t2.person_id
and t1.incumbencyStatus=1
and t2.active=TRUE
and t2.entryDate is null
and t1.entrydate is not null;


update security_person t1,security_company_person t2
set t2.entryDate = t1.entrydate
where t1.id =t2.person_id
and t1.incumbencyStatus=1
and t2.active=TRUE
and t2.entryDate is null
and t1.entrydate is not null;

update security_person t1,security_company_person t2
set t2.entryDate = t2.create_time
where t1.id =t2.person_id
and t1.incumbencyStatus=1
and t2.active=TRUE
and t2.entryDate is null
and t1.entrydate is null;

update security_person t1,security_company_person t2
set t2.leaveDate = t2.update_time
where t1.id =t2.person_id
and t2.active=false
and t2.leaveDate is null
and t1.leaveDate is null;

update security_person t1,security_company_person t2
set t2.leaveDate = t1.leaveDate
where t1.id =t2.person_id
and t2.active=false
and t2.leaveDate is null
and t1.leaveDate is not null;

update security_company_person t2
set t2.entryDate = t2.create_time
where t2.entryDate is null;


