当前位置:网站首页>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 .
边栏推荐
- The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation
- [OBS] encapsulate the basic process of OBS acquisition
- Event preview | the live broadcast industry "rolled in" to drive new data growth points with product power
- This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
- The excel table is transferred to word, and the table does not exceed the edge paper range
- 在CoreOS下部署WordPress实例教程
- Numpy np. Max and np Maximum implements the relu function
- Use typora to draw flow chart, sequence diagram, sequence diagram, Gantt chart, etc. for detailed explanation
- R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
- Excel快速跨表复制粘贴
猜你喜欢
[OBS] configFile in ini format of OBS
VS2015的下载地址和安装教程
PHP Basics
The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
牛牛的组队竞赛
ASP.NET-酒店管理系统
AI模型看看视频,就学会了玩《我的世界》:砍树、造箱子、制作石镐样样不差...
STL教程9-容器元素深拷贝和浅拷贝问题
rxjs Observable filter Operator 的实现原理介绍
How should intermediate software designers prepare for the soft test
随机推荐
cgroup简介
PHP server interacts with redis with a large number of close_ Wait analysis
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
Repo ~ common commands
Spl06-007 air pressure sensor (example of barometer)
Go语言实现静态服务器
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
MCDF实验1
Mmc5603nj geomagnetic sensor (Compass example)
DS90UB949
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
软考中级软件设计师该怎么备考
Dynamic programming (interval DP)
uniapp实现点击加载更多
STL教程10-容器共性和使用场景
2022 东北四省赛 VP记录/补题
C language two-dimensional array
优化接口性能