看起来是 table1 每一行对应多个地区(区域),每个地区有省市县三个维度。
table1( id,full_name ) 原来的 table1
area( id , province , city ,county ) 地区表 index1 province , city ,county ;index 2 city,county ;index 3 county
relation( id , table1id , areaid ) 关系表 index 1 table1id , areaid ;index 2 areaid, table1id
select t1.* from area a
inner join relation r
on
a.id = r.areaid
and a.province = xxx
and a.city = xxx
and a.county = xxx -- 或者别的过滤语句
inner join table1 t1
on r.table1id =
t1.id不知道地区名字你们怎么处理的,如果出现同样的编码改名,且要保留旧数据用旧名字的话,可以直接在 area 表里加名称字段以及启用日期和结束日期,查询的时候再根据时间过滤下就好了