原文:錯誤:You can't specify target table 'xxx' for update in FROM clause的解決

問題: 今天在MySQL數據庫刪除重復數據的時候遇到了一個問題。如下腳本: 會出現報錯信息: You can t specify target table tempA for update in FROM clause 大致意思是,在同一語句中,不能先select出同一表中的某些值,再update這個表。 解決方法: 需要對上述腳本進行改造,如下: 查詢的時候增加一層中間表,就可以避免該錯誤。 ...

2015-11-09 16:52 3 28896 推薦指數:

查看詳情

You can't specify target table 'xxx' for update in FROM clause

1、執行sql語句報上面的錯誤: 報錯如下所示You can't specify target table 'xxx' for update in FROM clause。 原因:因為在MYSQL里,不能先select一個表的記錄,在按此條件進行更新和刪除同一個表的記錄。 詳細 ...

Sun May 12 17:52:00 CST 2019 0 1188
You can't specify target table 'a' for update in FROM clause

項目中有一個功能變動上線,其中有一張表ttt的字段cc,歷史數據需要處理,把字段cc中為’xxx’的值替換為'yyy'。 表A結構如下: 更新sql如下: 執行報錯: Duplicate entry 'xx-xx-yyy' for key 'uk_aa_bb_cc' 因為相同的aa ...

Thu Feb 21 23:20:00 CST 2019 0 1887
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM