当前位置:网站首页>[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
2022-08-09 08:16:00 【Ctrl Trainee - Brother Xie blog】
raw sql
delete from at_phone where id not in(select id from at_phone where id!=1)
Run this sql statement, the result is an error
[Err] 1093 - You cannot specify target table 'at_phone' in FROM clause for update
Cause solution: If you want to add, delete, and modify in the form of a subquery in the addition, deletion and modification statement, you should select the subquery a second time and give the above table an alias before it can be executed.This second select actually puts the result set of the first select in a temporary table.
The resolved sql:
delete from at_phone where id not in(select * from (select id from at_phone where id!=1) a)
executed successfully
Summary
If you think it's good, you can like + bookmark or follow the blogger.Thanks for reading!
边栏推荐
猜你喜欢
随机推荐
收藏!Solidworks从设计到制造流程解决方案 2022来了!
App testing
SOLIDWORKS 2022新功能直播揭秘!速来围观!
3安装及管理程序
实现弹簧柔性状态的2种方式 | Solidworks教程
MySql作业练习题
Object detection app based on appinventor and EasyDL object detection API
OSI网络模型
The Servlet,
RAID配置实战
[STL]vector
eTS UI development learning
File Handling (IO)
【redis】redis之过期监听
Result consisted of more than one row
Boot process and service control
Win10电脑的WLAN消失的故事
Different styles of Flask-restful
监视文本框的输入
可能导致Loadrunner检查点中savecount为0的分析