delete from spn_prod.staff_responsibility;

insert into spn_prod.staff_responsibility
select 0 as id,
	concat('N',
            if(sss.staff < 10,
                LPAD(sss.staff, 2, '0'),
                sss.staff)) as staff_id,
	if( substring(ssj.YEAR, 1, 2) < 50, concat("20", substring(ssj.YEAR, 1, 2)), concat("19", substring(ssj.YEAR, 1, 2)) )as year,
	ssj.job as responsibility
FROM spn_staff.job ssj
left join spn_staff.staff sss on ssj.PID = sss.id
order by sss.staff, year desc;

update spn_prod.staff_responsibility set staff_id = "N403" where  staff_id = "N04"