当前位置:网站首页>[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!
边栏推荐
猜你喜欢
EMQ X message server learning record - prepare for the subsequent completion
Redis(七) 主从复制(二)哨兵模式
磁盘管理与挂载
EMQ X 消息服务器学习记录——为后面的毕设做准备
HOOPS助力 SolidWorks edrawings 引入AR/VR技术
世界顶尖3D Web端渲染引擎:HOOPS Communicator技术介绍(一)
Object detection app based on appinventor and EasyDL object detection API
NAT地址转换的原理与配置
[STL]list
[STL]string
随机推荐
P1064 金明的预算方案
OpenHarmony Light Smart Product Development Live Notes
VMware虚拟机强制关闭后,无法联网
LeetCode·每日一题·636.函数的独占时间·栈模拟
消息中间件(MQ)前置知识介绍(必看)
SQL存储过程
Account and Permission Management
文件处理(IO)
MySQL数据库
交换机的工作原理
web basic concepts
H3C_利用策略路由实现出口双线路负载(选路)的部署
Shell--常用小工具(sort、uniq、tr、cut)
3D精彩案例,清软英泰建成综合轻量化显示平台!
Collection 接口 & List 接口
eTS UI开发学习
897. Increasing Order Search Tree
The Martian - Simple Math Problems
Buns make up the number----Euclide+dp
[STL]vector