当前位置:网站首页>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 .
边栏推荐
- Kubernetes 三打探针及探针方式
- 按键切换:按F1-F12都需要按Fn
- phpcms 提示信息頁面跳轉showmessage
- How PHP solves the problem of high concurrency
- Application of high-precision indoor positioning technology in safety management of smart factory
- Yintai department store ignites the city's "night economy"
- Based on MCU, how to realize OTA differential upgrade with zero code and no development?
- Numpy np. Max and np Maximum implements the relu function
- 836. 合并集合(DAY 63)并查集
- 简单工厂和工厂方法模式
猜你喜欢
随机推荐
C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
CSRF
Kubernetes 三打探针及探针方式
利用Zabbix动态监控磁盘I/O
Redis things
同事写了一个责任链模式,bug无数...
Excel快速跨表复制粘贴
Extrapolated scatter data
Technical experts from large factories: how can engineers improve their communication skills?
Excel quick cross table copy and paste
After setting up ADG, instance 2 cannot start ora-29760: instance_ number parameter not specified
《剑指offer 03》数组中重复的数字
【学习笔记】dp 状态与转移
After using the thread pool for so long, do you really know how to reasonably configure the number of threads?
Cacti监控Redis实现过程
DS90UB949
Unity3D学习笔记5——创建子Mesh
Phpcms prompt message page Jump to showmessage
2022 northeast four provinces match VP record / supplementary questions
一文搞懂Go语言Context


![抓包整理外篇fiddler———— 会话栏与过滤器[二]](/img/04/e9cc027d753e7049f273d866eefdce.png)





