使用mysql update join优化update in的查询效率
发布时间:2024-12-31 07:33
'follow-up'用'update'或'reply'表示 #生活技巧# #职场沟通技巧# #商务英语#
对单表执行更新没有什么好说的,无非就是
update table_name set col1 = xx,col2 = yy where col = zz,
主要就是 where 条件的设置。有时候更新某个表可能会涉及到多张数据表,例如:
update table_1 set score = score + 5 where uid in (select uid from table_2 where sid = 10);
其实 update 也可以用到 left join、inner join 来进行关联,执行效率更高,把上面的 sql 替换成 join 的方式如下:
update table_1 t1 inner join table_2 t2 on t1.uid = t2.uid set score = score + 5 where t2.sid = 10;
网址:使用mysql update join优化update in的查询效率 https://www.yuejiaxmz.com/news/view/612533
下一篇:掌握复制粘贴,提升工作效率(如何
相关内容
MySQL update操作,执行顺序问题一份平民化的MySQL性能优化指南
MySQL优化:12种提升SQL执行效率的有效方法
MySQL慢查询优化
Oracle查询优化改写技巧与案例2.0
sql大查询left join拆分优化,去掉临时表
update优化案例
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT *、分页查询的优化、合理使用连接、子查询的优化)(上)
MySQL索引原理及慢查询优化(转载)
EXPLAIN FORMAT=json和EXPLAIN ANALYZE查询计划解读