批量修改行政区划
--行政區(qū)劃表
drop table if exists sys_division;
/*==============================================================*/
/* Table: sys_division ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/
/*==============================================================*/
create table sys_division
(
? ?division_id ? ? ? ? ?int not null auto_increment comment '行政區(qū)劃主鍵',
? ?division_code ? ? ? ?varchar(32) comment '行政區(qū)劃編碼',
? ?division_name ? ? ? ?varchar(50) comment '行政區(qū)劃名稱(chēng)',
? ?division_father ? ? ?varchar(32) comment '父行政區(qū)劃',
? ?primary key (division_id)
);
--使用MySQL Workbench向?qū)腅xcel文件批量導(dǎo)入行政區(qū)劃數(shù)據(jù)
-- 查詢(xún)所有行政區(qū)劃
select * from sys_division;
--查詢(xún)所有市級(jí)行政區(qū)劃
select count(*) from book.sys_division where division_id like '%0000';
--查詢(xún)所有縣級(jí)行政區(qū)劃
select count(*) from book.sys_division where division_id like '%00';
-- 統(tǒng)計(jì)所有行政區(qū)劃
select count(*) from sys_division;
--批量修改行政區(qū)劃編碼
update sys_division set division_id = division_code;
--批量修改父行政區(qū)劃
update sys_division set division_father = null;
--批量修改市級(jí)父行政區(qū)劃
update book.sys_division set division_father = CONCAT(substr(division_id, 1, 2), '0000') where division_id not like '%0000';
--批量修改縣級(jí)父行政區(qū)劃(北京、天津、上海、重慶是直轄市)
update book.sys_division set division_father = CONCAT(substr(division_id, 1, 4), '00') where division_id not like '%00' and division_id not like '11%' and division_id not like '12%' and division_id not like '31%' and division_id not like '50%' ;
總結(jié)
- 上一篇: rx560d linux 图形设计,RX
- 下一篇: python 内置方法 BUILT-I