业务前景:在旧表中新增ch类型字段,以ch字段作为查询条件,为了不产生影响,需要对ch字段进行更新操作,ch字段源于base字段 json格式中的一部分。

解决方案:
1) 字段迁移
update reported_data set ch = base;
2) 查询后更新
update reported_data set ch = ( SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(ch,'"',8),'"',-1) AS ch_ from (SELECT * from reported_data) test WHERE reported_data.id = test.id )