MySQL update join优化update in的查询效率
对单表执行更新没有什么好说的,无非就是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
上一篇:MySql Join语法解析与性能分析 下一篇:JS获取当月第一天和最后一天
相关阅读
MySQL-5.6.14-winx64的...MySql优化方案总结MySql还原失败,还原大...MySql数据库中如何设置...C# MVC MySql插入数据...MYSQL错误号大全MySQL与PostgreSQL:该...