当前位置:网站首页>MySQL uses the method of updating linked tables with update
MySQL uses the method of updating linked tables with update
2022-07-03 11:43:00 【Never stop chasing dreams】
One 、 Preface
Before that java In the code , branch 2 step :
1. Use select Query a result set
2. According to this result set , Use update Method to update the database
Two 、sql
Now you need not to change the code , use sql To achieve this step , A sample of :
update a cs inner join
(
SELECT cs.class_id,cs.user_id FROM a cs,b ss
WHERE cs.class_id = ss.classid AND cs.user_id = ss.user_id
AND cs.isDel IS NULL
AND ss.num >=10
) rrr on cs.user_id=rrr.user_id and cs.class_id=rrr.class_id
set cs.type = '1';
explain :
1.sql There is a piece in it , First, query a qualified result set
2. And then update a surface , Use the data in the qualified result set , Put the right a Exterior and interior type Change to 1.
3、 ... and 、 remarks
There's another way , You can put the qualified a Tabular id Find out , And then update a Tabular type when , according to id to update , Use multiple update Statement or use in Any sentence will do .
边栏推荐
- R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
- Numpy np. Max and np Maximum implements the relu function
- (数据库提权——Redis)Redis未授权访问漏洞总结
- Mysql根据时间搜索常用方法整理
- 软件测试周刊(第78期):你对未来越有信心,你对现在越有耐心。
- Use typora to draw flow chart, sequence diagram, sequence diagram, Gantt chart, etc. for detailed explanation
- Redis things
- How to mix embedded MCU, arm and DSP?
- STL教程10-容器共性和使用场景
- [OBS] encapsulate the basic process of OBS acquisition
猜你喜欢
Processes and threads
Numpy np.max和np.maximum实现relu函数
银泰百货点燃城市“夜经济”
牛牛的组队竞赛
用了这么久线程池,你真的知道如何合理配置线程数吗?
The excel table is transferred to word, and the table does not exceed the edge paper range
Cadence background color setting
Gut | Yu Jun group of the Chinese University of Hong Kong revealed that smoking changes intestinal flora and promotes colorectal cancer (do not smoke)
鸿蒙第四次培训
PHP Basics
随机推荐
ASP. Net hotel management system
After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
uniapp实现点击加载更多
导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....
Viewing binary bin files with notepad++ editor
Event preview | the live broadcast industry "rolled in" to drive new data growth points with product power
Redis things
Mysql根据时间搜索常用方法整理
STL教程8-map
Gut | Yu Jun group of the Chinese University of Hong Kong revealed that smoking changes intestinal flora and promotes colorectal cancer (do not smoke)
PHP Basics
Go语言实现静态服务器
[OBS] encapsulate the basic process of OBS acquisition
MySQL union和union all区别
STL教程9-容器元素深拷贝和浅拷贝问题
How to get started embedded future development direction of embedded
并发编程-单例
【学习笔记】dp 状态与转移
基于turtlebot3实现SLAM建图及自主导航仿真
(database authorization - redis) summary of unauthorized access vulnerabilities in redis