MySQL 批量更新数据
时间:2020-03-24
本文章向大家介绍MySQL 批量更新数据,主要包括MySQL 批量更新数据使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
1、首先用查出来要处理的sql,准备更新用
-- 查询承租人对应的all表的guid select c.guid as zf_guid,al.guid as guid_all from ( select i.id,o.guid, o.renter_id as guid_info,i.orgid,info.idcard as idcard_info from t_rental_house_oper_info_20200323 o left join t_rental_house_info_20200323 i on o.rental_houseid=i.id left join building_resident_info info on o.renter_id=info.guid where o.status='1' and i.status='1' and o.renter_id is not null and info.idcard is not null ) c left join building_resident_all al on c.orgid=al.orgid and c.idcard_info=al.idcard
效果:
2、然后,更新语句 把上面的sql结果集,当作一张表来用,我这别名为 v 的,是上面的结果集,后面再写set和where条件
-- 更新的时候把结果集当作一张表来用 update t_rental_house_oper_info_20200323 a ,( select c.guid as zf_guid,al.guid as guid_all from ( select i.id,o.guid, o.renter_id as guid_info,i.orgid,info.idcard as idcard_info from t_rental_house_oper_info_20200323 o left join t_rental_house_info_20200323 i on o.rental_houseid=i.id left join building_resident_info info on o.renter_id=info.guid where o.status='1' and i.status='1' and o.renter_id is not null and info.idcard is not null ) c left join building_resident_all al on c.orgid=al.orgid and c.idcard_info=al.idcard ) v set a.guid_all=v.guid_all where a.guid=v.zf_guid
效果:
原文地址:https://www.cnblogs.com/w-yu-chen/p/12557558.html
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- java8新特性总结备忘
- 商业数据分析从入门到入职(6)Python程序结构和函数
- 数据科学家极力推荐核心计算工具-Numpy的前世今生(下)
- Android 重构 | 持续优化统一管理 Gradle
- 快速学习-XXL-JOB调度中心/执行器 RESTful API
- 快速学习-XXL-JOB快速入门
- binlog2sql,你该知道的数据恢复工具
- java反射总结
- 玩转dnmp之port篇
- 玩转dnmp之自定义容器
- python那些实用且不为人知的技巧
- 实现接口的契约测试
- java泛型总结
- 彻底搞懂 etcd 系列文章(九):etcd compact 和 watch API
- lru算法和redis的lru