update t02, z_tameia_t02
set t02.p201 = z_tameia_t02.p201, 
    t02.p30 = z_tameia_t02.p30
where t02.p01=z_tameia_t02.p01;
/*peg_end*/

insert into t02
(nr01, p01, p02, p03, p04, p05, p07, p08, p09, p010, p011, p0101, p0102, p0901, p0902, p0903, p201, p30, 
remdate, remtime, remuser, remfdate, remftime, remfuser)

select z_tameia_t02.nr01 as nr01, 
       z_tameia_t02.p01 as p01, 
       z_tameia_t02.p02 as p02, 
       z_tameia_t02.p03 as p03, 
       z_tameia_t02.p04 as p04, 
       z_tameia_t02.p05 as p05, 
       z_tameia_t02.p07 as p07, 
       z_tameia_t02.p08 as p08, 
       z_tameia_t02.p09 as p09, 
       z_tameia_t02.p010 as p010, 
       z_tameia_t02.p011 as p011, 
       z_tameia_t02.p0101 as p0101, 
       z_tameia_t02.p0102 as p0102, 
       z_tameia_t02.p0901 as p0901, 
       z_tameia_t02.p0902 as p0902, 
       z_tameia_t02.p0903 as p0903, 
       z_tameia_t02.p201 as p201, 
       z_tameia_t02.p30  as p30, 

       curdate() as remdate, 
       curtime() as remtime, 
       z_tameia_t02.remuser as remuser, 
       z_tameia_t02.remfdate as remfdate, 
       z_tameia_t02.remftime as remftime, 
       z_tameia_t02.remfuser as remfuser 

from z_tameia_t02
LEFT JOIN t02 ON t02.p01=z_tameia_t02.p01
WHERE t02.nr01 is null;
/*peg_end*/
