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'
1、要更新的數據大概 有10W多條 然后 我執行了下 結果 2個小時了 還是沒 執行成功
pdate table1 t set t.column1 =0 where t.id in (select id from table2)
2、 sql 改成
update table1 t ,table2 b set t.column1=0 where t.id=b.id
幾秒鍾就執行成功 !!!