表1

表2

通過兩個表的auid 相同,來更新表2 中的F1,如果直接用:
update table2 t2 ,table1 t1 set t2.f1=1 where t2.auid = t1.auid
在mysql 中執行報錯為死鎖
為解決此問題:
改為:
update table2 t2 set t2.f1=1 where t2.auid in (select distinct auid from table1)
但是這樣 速度還是太慢
改為:
update com_tab_copy set f1 = 1 where auid in (select auid from (select distinct auid from ar_copy)as t1);
速度有很大的提升
