更新行政区域的父级行政区代码
UPDATE system_region,(
SELECT
system_region.id,
system_region.`code`,
system_region.full_name,
temp1.full_name province,
temp2.full_name city,
temp1.`code` provinceCode,
temp2.`code` cityCode
FROM
system_region
LEFT JOIN system_region temp1 ON temp1.`code` = CONCAT(LEFT(system_region.`code`,2),'0000') AND system_region.`code` != CONCAT(LEFT(system_region.`code`,2),'0000')
LEFT JOIN system_region temp2 ON temp2.`code` = CONCAT(LEFT(system_region.`code`,4),'00') AND system_region.`code` != CONCAT(LEFT(system_region.`code`,4),'00')
) t
SET
parent_code = IF(t.cityCode, t.cityCode, t.provinceCode)
WHERE
system_region.id = t.id