10.24、25第十四、十五天

1.用信息列表jazs_zzdf_community_list1024更新info_dictionary
新表数据922条
(1)街道是空数据
7 东丽区 164 丰年村街道 Null Null 902
(2)社区空但街道不空的数据
14条

问题数据
①一级 红桥区3
②二级名字和senior_id匹配问题
Null 东丽区 7
芥园街道 红桥区 3

③三级名字和senior_id匹配问题(855个)
#按照老信息表to_stat_rev结构创建临时信息表to_stat_temp

create table if not exists to_stat_temp(like community_list1024);
truncate table to_stat_temp;

#修正street_id 至to_stat_temp表
insert into to_stat_temp
(district_id,district_name,street_id,street_name,community_name,community_id)
select community_list1024.district_id, community_list1024.district_name, info_dictionary.region_id , community_list1024.street_name, community_list1024.community_id, community_list1024.community_name
from community_list1024,info_dictionary
where community_list1024.street_name=info_dictionary.region_name
and community_list1024.district_id=info_dictionary.senior_id;


2.字典info_dictionary的构造方法。

①通过用老字典与最新数据匹配,找到老字典表匹配不上的新数据
②对找到的新数据处理
a.空数据:二级名为空的数据忽略;
三级名为空二级名不空的数据只修改二级名对应id
b.找到名字能匹配上但id匹配补上的数据:
可能是不同二级的同三级名问题(去base表找数据源添加新数据);也可能是张冠李戴问题(忽略不计)
c.找到名字id都匹配不上的数据——看属于字典三大类的哪个类别
a.能与tc_region匹配上
直接从tc_region中获取数据插入到字典表
b.不满足a但是能与base_region匹配上
在base表中找二三级对应关系,去tc表中找id,插入到字典表
c.不满足ab
以3或4开头造9位数的新id,插入到字典表
3.修改数据sql语句


#sql缓存
select count(*) from community_list1024
where street_name ='Null';

select count(*) from community_list1024
where community_name ='Null';

select count(*) from community_list1024
GROUP BY community_name;

#查看二级名&senior_id的匹配情况
select count(*)
from community_list1024,info_dictionary
where community_list1024.street_name=info_dictionary.region_name and community_list1024.district_id=info_dictionary.senior_id;

#查看二级名&senior_id的匹配时的问题数据
select community_list1024.street_name,community_list1024.district_name,community_list1024.district_id
from community_list1024 left join info_dictionary
on community_list1024.street_name=info_dictionary.region_name and community_list1024.district_id=info_dictionary.senior_id
where info_dictionary.region_name is null;


#查看三级名&senior_id的匹配情况852/892
select count(*) from to_stat_temp,info_dictionary
where to_stat_temp.community_name=info_dictionary.region_name
and to_stat_temp.street_id=info_dictionary.senior_id;


#查看三级名&senior_id的匹配时的问题数据52个
select to_stat_temp.community_name,to_stat_temp.street_name
from to_stat_temp left join info_dictionary
on to_stat_temp.community_name=info_dictionary.region_name
and to_stat_temp.street_id=info_dictionary.senior_id
where info_dictionary.region_name is null
and community_name !='Null';

原文地址:https://www.cnblogs.com/StarZhai/p/11750276.html