1. 程式人生 > >【處理】Table is specified twice, both as a target for 'UPDATE' and as a separate source for data

【處理】Table is specified twice, both as a target for 'UPDATE' and as a separate source for data

【錯誤內容】:Error Code: 1093. Table '表名' is specified twice, both as a target for 'UPDATE' and as a separate source for data

【錯產生經過】:update t_test1 set col1= col1_value where val1 in(select val1 from t_test2 group by val1);

【解決辦法】:update t_test1 set col1= col1_value where val1 in(select * from (select val1 from t_test2 group by val1) as T);

注意:經測試delete時,也存在這種情況