同表中字段A的值赋给B
要求是将ward_code为12位的值截取9位再从ward_code里面查这个9位的ward_code对应的ward_name赋给village_name
------解决方案--------------------
update test t1 set t1.willage_name=(select ward_name from test t2 where t2.ward_code=substr(t1.ward_code,1,9)) where length(t1.ward_code)=12;
------解决方案--------------------UPDATE city_village_code t1
SET village_name = (
SELECT
ward_name
FROM
city_village_code WHERE
ward_code = substr(t1.ward_code, 1, 9)
)
WHERE
length(t1.ward_code) = 12;