MySQL錯誤

一、mysql中You can't specify target table for update in FROM clause錯誤的意思是說,不能先select出同一表中的某些值,再update這個表(在同一語句中)。 例以下面這個sql:mysql

  delete form t_area where area_id = (select area_id from t_area limit 1,1);sql

出現錯誤提示爲:oracle

 

解決辦法:orm

delete from t_area where area_id=(select ta.area_id from (select area_id from t_area limit %s,1) ta);ci

說明:get

     將select出的結果再經過中間表select一遍,這樣就規避了錯誤。注意,這個問題只出現於mysql,mssql和oracle不會出現此問題it

相關文章
相關標籤/搜索