mysql update in执行效率优化

1、常用的mysql执行更新操作语句如下:

UPDATE table1 set num = num + 1 where id in (SELECT id FROM table2 WHERE date>'2017-05-09)

in条件的更新效率可优化使用join语法;
2、join预发更新操作

UPDATE table1 t1 INNER JOIN table2 t2 on t1.id = t2.id set t1.num = t1.num + 1 where t2.date>'2017-05-09'


猜你喜欢

转载自blog.csdn.net/aiyawalie/article/details/71464492