[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相关推荐

  1. [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 ...

  2. 解决——》[Err] 1093 - You can't specify target table 'fcf' for update in FROM clause

    版权声明:本文为博主原创文章,无需授权即可转载,甚至无需保留以上版权声明,转载时请务必注明作者. https://blog.csdn.net/weixin_43453386/article/detai ...

  3. 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); 会报出错 ...

  4. 记录一个多表查询的问题 #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 ...

  5. 【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 错误的 ...

  6. 全网详细解决1093 - You can‘t specify target table ‘xxx‘ for update in FROM clause的错误

    文章目录 1. 复现错误 2. 分析错误 3. 解决错误 1. 复现错误 今天在工作时,接到一个新需求,就是将app_page_button表中的label_code字段修改为edit,条件如下: 只 ...

  7. 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 ...

  8. 【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, ...

  9. 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 ...

最新文章

  1. ef linq 中判断实体中是否包含某集合
  2. 蛋花花谈Web开发到底要不要加入人工智能
  3. 祝贺!屠呦呦再获国际大奖!一文读懂:神药青蒿素那些我们不知道的事
  4. HashMap的工作原理
  5. 30万奖金海华AI挑战赛 | 用机器挑战中文阅读理解
  6. OpenCV findContours和drawContours用法的实例(附完整代码)
  7. C和C++线性表的链式存储
  8. linux下启动oracle服务
  9. ajax请求拿到多条数据拼接显示在页面中
  10. python bottle部署g_python bottle框架(WEB开发、运维开发)教程 | linux系统运维
  11. Unity开发《一起来捉妖》教程 | 1.陀螺仪控制相机
  12. 建议收藏!前端工程师一线大厂面试2021总结篇(50个JS常问知识点)
  13. 从月薪 1000 到 2W+,文科生如何逆袭成为大厂程序员?
  14. c 子类对象 访问父类对象受保护成员_看了这个,你就会搞对象了
  15. 如何使用ssh工具便于远程管理
  16. oracle vb 用法,oracle客户端配置与使用(vb)
  17. tomcat source code in eclipse
  18. 思科服务器中ftp的配置文件,思科服务器ftp的配置
  19. c语言编程实现开平方运算,详细解析C语言中的开方实现
  20. 使用Lens管理多云Kubernetes

热门文章

  1. Stanford Parser的学习之开篇(一)
  2. 机器学习经典书籍论文
  3. 安装Docker环境并下载TensorFlow镜像
  4. 地图小部件—ArcGIS API for JavaScript
  5. Android ListView 中文API
  6. 基于进程的游戏Server端架构设计
  7. Visual C# 资源文件编程--创建资源文件
  8. android通知栏应用程序更新,Android App自动更新之通知栏下载
  9. anaconda3环境整体打包放在Spark集群上运行
  10. spark和hadoop的区别