惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
T
Troy Hunt's Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Know Your Adversary
Know Your Adversary
L
Lohrmann on Cybersecurity
SecWiki News
SecWiki News
S
Security Affairs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
Intezer
S
Secure Thoughts
罗磊的独立博客
Attack and Defense Labs
Attack and Defense Labs
G
GRAHAM CLULEY
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园_首页
Cyberwarzone
Cyberwarzone
IT之家
IT之家
T
Threatpost
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
博客园 - 叶小钗
Cloudbric
Cloudbric
量子位
Scott Helme
Scott Helme
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
O
OpenAI News
C
Cyber Attacks, Cyber Crime and Cyber Security
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cybersecurity and Infrastructure Security Agency CISA
J
Java Code Geeks
有赞技术团队
有赞技术团队
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
宝玉的分享
宝玉的分享
P
Privacy International News Feed
A
Arctic Wolf
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
云风的 BLOG
云风的 BLOG

博客园 - 哈喽哈喽111111

RockyLinux SSH 跳板转发 3389(Windows 远程桌面)完整方案 MySQL使用自带的logrotate配置日志轮转 yum方式安装redis7 nacos新加用户操作 网络运营商禁止端口信息 Linux开机启动rc.local不生效的一般解决方案 Nginx流量拷贝ngx_http_mirror_module模块使用方法详解 Adobe 修改 hosts 文件 axios 投毒与好莱坞式骗术 Linux系统在使用systemctl启动服务的失败,报错如下:Error No space left on device git submodule 的增、查、改、删 Rocky Linux 安装 Google Chrome 浏览器 “头号玩家”—— 美国技术霸权下的全球虚拟货币资产收割行动深层解析 你是第几级 AI 编程 Linux 的 Port Knocking 端口碰撞(端口敲门) MySQL解除死锁 jar文件解压缩操作 设置Windows服务器远程桌面能使用多个桌面 20251024- 使用shell脚本分库定时备份MySQL数据 禁用sentinel 在 Linux 中安装和配置 NTP 服务器和 NTP 客户端 springboot配置文件关系及加载顺序 用自带的Nginx为gitlab做白名单 Rocky9和Ubuntu使用pip安装python的库mysqlclient失败解决方式 在Spring Boot Admin中根据Nacos的命名空间来区分和管理不同的环境
MySQL中通过关联update将一张表的一个字段更新到另外一张表中
哈喽哈喽111111 · 2025-12-20 · via 博客园 - 哈喽哈喽111111

做什么事情
更新book_borrow表,
设置其中的student_name为student表中的name,
关联条件为book_borrow.student_id = student_id
图片

几种不同的更新方式
保留原表数据的更新
只会更新student表中有的数据,student表中查不到的数据,在book_borrow表中还保持不变,不会更新,相当于内连接
update book_borrow br,student st set br.student_name = st.name where br.student_id = st.id;
图片

全部以右表数据为准
更新结果以student的查询结果为准,student中没有查到的记录会全部被更新为null 相当于外连接
update book_borrow br set student_name = (select name from student where id = br.student_id);
update book_borrow br left join student st on br.student_id = st.id set br.student_name = st.name;  

图片

将一张表的查询结果插入到另外一张表中
insert select :将一条select语句的结果插入到表中
-- insert into 表名1 (列名) select (列名) from 表名2 ;
insert into tableA(columnA) select columnA from tableB where id=1