我得到了一個「錯誤「#1093 - 你不能指定目標表‘在FROM子句更新T1’」與此代碼:MYSQL - 在同一個表子查詢的WHERE UPDATE語句的WHERE子句
UPDATE `table1` t1 SET t1.name = 'abc'
WHERE t1.id = 165 AND NOT EXISTS (
SELECT t2.id FROM `table1` t2 WHERE t2.id != 165 AND t2.name = 'abc'
)
但與代碼沒有問題:
UPDATE `table1` t1 SET t1.name = 'abc'
WHERE t1.id = 165 AND NOT EXISTS (
SELECT t2.id FROM `table2` t2 WHERE t2.id != 165 AND t2.name = 'abc'
)
我是怎麼會錯呢?
的【如何解決MySQL錯誤「不能爲更新指定目標表X FROM子句」?]可能的複製(https://stackoverflow.com/questions/37251621/how-to-resolve-mysql-錯誤您-着-指定目標表-X-用於更新功能於從) – JYoThI