当前位置:网站首页>MySQL根据查询的数据更新记录
MySQL根据查询的数据更新记录
2022-06-26 01:34:00 【哈希疯】
更新行政区域的父级行政区代码
UPDATE system_region,(
SELECT
system_region.id,
system_region.`code`,
system_region.full_name,
temp1.full_name province,
temp2.full_name city,
temp1.`code` provinceCode,
temp2.`code` cityCode
FROM
system_region
LEFT JOIN system_region temp1 ON temp1.`code` = CONCAT(LEFT(system_region.`code`,2),'0000') AND system_region.`code` != CONCAT(LEFT(system_region.`code`,2),'0000')
LEFT JOIN system_region temp2 ON temp2.`code` = CONCAT(LEFT(system_region.`code`,4),'00') AND system_region.`code` != CONCAT(LEFT(system_region.`code`,4),'00')
) t
SET
parent_code = IF(t.cityCode, t.cityCode, t.provinceCode)
WHERE
system_region.id = t.id
边栏推荐
- Breadth first traversal of Graphs
- leetcode 300. Longest increasing subsequence (medium)
- Introduction to bloc: detailed explanation of cube
- OpenAPI 3.0 specification - Food Guide
- 【缺陷检测】基于matlab GUI印刷电路板自动缺陷检测【含Matlab源码 1912期】
- 基于邻接矩阵的深度优先遍历实现
- . Net7 miniapi (special part):preview5 optimizes JWT verification (Part 2)
- Blazor University (33) form - editcontext, fieldidentifiers
- The programmer's eight-year salary change has made netizens envious: you pay me one year's salary per month
- 基于邻接表的广度优先遍历
猜你喜欢
随机推荐
Graduation summary of cloud native training camp
基于邻接矩阵的深度优先遍历实现
网上开户选哪个证券公司?网上开户是否安全么?
What happens when the cloud answer does not display the third-party login button
股票开户怎么开户?网上开户是否安全么?
Timer case
Breadth first traversal based on adjacency matrix
[defect detection] automatic defect detection of printed circuit board based on Matlab GUI [including Matlab source code 1912]
微博评论的高性能高可用计算架构
100002nd prime
Depth first traversal of Graphs
数字商品DGE--数字经济的财富黑马
第一章:渗透测试的本质信息收集
喜讯 | 祝贺Apache Linkis(incubating) 社区新增5位Committer
Magnifier case
Which securities company should I choose to open an account online? Is it safe to open an account online?
Matlab|基于BP神经网络进行电力系统短期负荷预测
数据库的授权
Remember a simple JVM tuning experience
Multi surveyor Gongshu Xiao sir_ The solution of using websocket error reporting under working directory