insert into spn_prod.staff_educational
SELECT 0 as id,
		concat('N',
            if(sss.staff < 10,
                LPAD(sss.staff, 2, '0'),
                sss.staff)) as staff_id,
		ssq.SCHOOL as school,
		ssq.QUAL as proval,
		ssq.DATE as date,
		if(ssq.QUAL_CAT_ID = 99, 8, ssq.QUAL_CAT_ID) as type,
		null as attachment
FROM spn_staff.qual ssq
left join spn_staff.staff sss on ssq.PID = sss.id
order by sss.staff