[Err] 1093 - You can't specify target table 's' for update in FROM clause
[Err] 1093 - You can't specify target table 's' for update in FROM clause
执行SQL
DELETE from book WHERE id IN(
SELECT id FROM (SELECT id,name FROM book WHERE name IN(
SELECT name FROM book GROUP BY name HAVING count(name) > 1
) ) t WHERE id NOT IN (
SELECT id FROM book GROUP BY name HAVING count(name) > 1));
出现错误:
[Err] 1093 - You can't specify target table 's' for update in FROM clause
执行SQL语句时出现这个错误。原因是在更新这个表和数据时又查询了它,而查询的数据又做了更新的条件
解决方法:把要删除的数据查询出来做为一个第三方表,然后进行删除。
DELETE book from book ,
(SELECT id FROM (SELECT id FROM book WHERE name IN(SELECT name FROM book GROUP BY name HAVING count(name) > 1) ) t WHERE id NOT IN (SELECT id FROM book GROUP BY name HAVING count(name) > 1)
) as a
WHERE book.id = a.id;
转载于:https://www.cnblogs.com/new0801/p/6146607.html
[Err] 1093 - You can't specify target table 's' for update in FROM clause相关推荐
- [Err] 1093 - You can't specify target table 'xxx' for update in FROM clause解决方法
执行开发同学提供的删除数据的sql时报错[Err] 1093 - You can't specify target table 'run_result' for update in FROM clau ...
- 解决——》[Err] 1093 - You can't specify target table 'fcf' for update in FROM clause
版权声明:本文为博主原创文章,无需授权即可转载,甚至无需保留以上版权声明,转载时请务必注明作者. https://blog.csdn.net/weixin_43453386/article/detai ...
- MySQL [1093] You can‘t specify target table ‘titles_test‘ for update in FROM clause
执行以下语句: delete from titles_test where id not in(select min(id)from titles_testgroup by emp_no); 会报出错 ...
- 记录一个多表查询的问题 #1093 - You can‘t specify target table ‘xxx‘ for update in FROM clause
SQL里面,多表查询比较常见,用法也比较简单 可以是 SELECT ood.oodId, ood.status, ood.userId, orders.createdAt FROM ood, orde ...
- 【MySQL】Error Code: 1093. You can‘t specify target table ‘xxx‘ for update in FROM clause
1. 报错信息: Error Code: 1093. You can't specify target table 'self_check' for update in FROM clause 错误的 ...
- 全网详细解决1093 - You can‘t specify target table ‘xxx‘ for update in FROM clause的错误
文章目录 1. 复现错误 2. 分析错误 3. 解决错误 1. 复现错误 今天在工作时,接到一个新需求,就是将app_page_button表中的label_code字段修改为edit,条件如下: 只 ...
- You can't specify target table 'ship_product_cat' for update in FROM clause
有时候我们在编辑update时需要select作为条件,在mysql中有时会出现这样的错误:You can't specify target table for update in FROM clau ...
- 【mysql 】sql错误代码 1093 You cannot specify target table xxxx for update in FROM clause
在mysql8.X中执行如下语句: DELETE FROM`test`.unsign_wocode WHEREid IN (SELECTa.id FROM`test`.unsign_wocode a, ...
- ERROR 1093 (HY000): You can‘t specify target table ‘info‘ for update in FROM clause
MYSQL执行如下语句报错: mysql> delete from info where id in (select id from info where name=''); ERROR 109 ...
最新文章
- ef linq 中判断实体中是否包含某集合
- 蛋花花谈Web开发到底要不要加入人工智能
- 祝贺!屠呦呦再获国际大奖!一文读懂:神药青蒿素那些我们不知道的事
- HashMap的工作原理
- 30万奖金海华AI挑战赛 | 用机器挑战中文阅读理解
- OpenCV findContours和drawContours用法的实例(附完整代码)
- C和C++线性表的链式存储
- linux下启动oracle服务
- ajax请求拿到多条数据拼接显示在页面中
- python bottle部署g_python bottle框架(WEB开发、运维开发)教程 | linux系统运维
- Unity开发《一起来捉妖》教程 | 1.陀螺仪控制相机
- 建议收藏!前端工程师一线大厂面试2021总结篇(50个JS常问知识点)
- 从月薪 1000 到 2W+,文科生如何逆袭成为大厂程序员?
- c 子类对象 访问父类对象受保护成员_看了这个,你就会搞对象了
- 如何使用ssh工具便于远程管理
- oracle vb 用法,oracle客户端配置与使用(vb)
- tomcat source code in eclipse
- 思科服务器中ftp的配置文件,思科服务器ftp的配置
- c语言编程实现开平方运算,详细解析C语言中的开方实现
- 使用Lens管理多云Kubernetes