国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

mysql中You can’t specify target table for update in FROM clau

2024-07-24 12:46:26
字體:
供稿:網(wǎng)友

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

復制代碼 代碼如下:

delete from tbl where id in
(
        select max(id) from tbl a where EXISTS
        (
            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1
        )
        group by tac
)

改寫成下面就行了:

復制代碼 代碼如下:

delete from tbl where id in
(
    select a.id from
    (
        select max(id) id from tbl a where EXISTS
        (
            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1
        )
        group by tac
    ) a
)

也就是說將select出的結(jié)果再通過中間表select一遍,這樣就規(guī)避了錯誤。注意,這個問題只出現(xiàn)于mysql,mssql和oracle不會出現(xiàn)此問題。

您可能感興趣的文章:

mysql中錯誤:1093-You can’t specify target table for update in FROM clause的解決方法mysql “ Every derived table must have its own alias”出現(xiàn)錯誤解決辦法讀取mysql一個庫下面的所有的表tableMySQL無法重啟報錯Warning: World-writable config file ‘/etc/my.cnf’ is ignored的解決方法mysql Event Scheduler: Failed to open table mysql.event出現(xiàn)錯誤mysql Table ''performance_schema...解決辦法
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 五华县| 高青县| 东方市| 南乐县| 潢川县| 旺苍县| 蕉岭县| 嵊州市| 观塘区| 双牌县| 余姚市| 磴口县| 新密市| 贵定县| 曲周县| 得荣县| 惠水县| 咸阳市| 磐安县| 普兰店市| 巴塘县| 长岛县| 通化市| 兴安盟| 溧水县| 唐河县| 宜春市| 米易县| 大埔区| 舒城县| 平湖市| 太白县| 大港区| 毕节市| 乐业县| 正阳县| 政和县| 双柏县| 墨竹工卡县| 黔南| 福贡县|