1. 程式人生 > >【update】update中無法用基於被更新表的子查詢,You can't specify target table 'test1' for update in FROM clause.

【update】update中無法用基於被更新表的子查詢,You can't specify target table 'test1' for update in FROM clause.

子查詢 src nbsp spec tab can 技術分享 例如 bubuko

update中無法用基於被更新表的子查詢,You can‘t specify target table ‘test1‘ for update in FROM clause.

情況如下:

(1)第1行更新語句中,update表與子查詢中表一樣,所以報錯

(2)第2行更新語句中,update表與子查詢中表不一樣,所以可以執行。

技術分享圖片

如何解決?

把子查詢換成join即可。

例如:

技術分享圖片

【update】update中無法用基於被更新表的子查詢,You can't specify target table 'test1' for update in FROM clause.