INSERT INTO new_school(s_code)
SELECT DISTINCT s_code
FROM school
UPDATE new_school LEFT JOIN school ON new_school.s_code = school.s_code
SET new_school.s_name = school.s_name
WHERE new_school.s_code = school.s_code
INSERT INTO new_student( syear, s_code, c_code,g_code, count )
SELECT student.year, student.s_code, student.c_code,student.g_code, student.count
FROM new_school, student
WHERE student.s_code = new_school.s_code
SELECT student.year, student.s_code, student.c_code,student.g_code, student.count
FROM new_school, student
WHERE student.s_code = new_school.s_code