Mysql update语句赋值嵌套select语句:

update UpdateInfo set Numofupdate=Numofupdate+1 where Id=(select MAX(Id) from UpdateInfo)

结果出现错误:

You can't specify target table 'UpdateInfo' for update in FROM clause

这个错误只有在mysql数据库中才会出现,意思是:在同一语句中,不能先select出同一表,再直接update这个表。

可以将SELECT出的结果再通过中间表SELECT一遍来进行解决:

update UpdateInfo set Numofupdate=Numofupdate+1 where Id=(select * from (select MAX(Id) from UpdateInfo) as b)

You can't specify target table 'UpdateInfo' for update in FROM clause相关推荐

  1. 错误:You can't specify target table 'xxx' for update in FROM clause的解决

    今天在MySQL数据库删除重复数据的时候遇到了一个问题.如下脚本: DELETE FROM tempA WHERE tid IN ( SELECT MAX(tid) AS tid FROM tempA ...

  2. MySQL 语法问题:You can‘t specify target table ‘xxx‘ for update in FROM clause. 原因及解决方法

    报错信息如下: [Code: 1093, SQL State: HY000] You can't specify target table 'bd_bankaccbas' for update in ...

  3. You can't specify target table 'TS_AUTH_ADMIN' for update in FROM clause记录

    1. 报错:You can't specify target table 'TS_AUTH_ADMIN' for update in FROM clause, 百度查到说是,不能在同一语句中先sele ...

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

  5. [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 WHE ...

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

  7. MySQL||SQL_ERROR_INFO: “You can‘t specify target table ‘titles_test‘ for update in FROM clause“

    一.问题描述 假定test数据库存在表titles_test,表内数据如下: 先要求删除emp_no重复的记录,只保留最小的id对应的记录.编写代码如下: delete from titles_tes ...

  8. 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); 入上述操作会报错: ...

  9. mysql实战(五)—— You can‘t specify target table ‘org_department‘ for update in FROM clause

    系列文章目录 You can't specify target table 'org_department' for update in FROM clause 系列文章目录 背景 具体实现过程 1. ...

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

最新文章

  1. error: failed linking file resources
  2. 安卓给string对象赋值_String 面试题!看完让你恍然大悟!
  3. autotype安全 fastjson_Fastjson 安全更新,建议升级到 1.2.28 或更新版本
  4. 杂牌手柄模拟xboxone手柄_手机就能玩Switch游戏,蛋蛋模拟器+盖世小鸡X2手柄体验...
  5. mybatis思维导图,让mybatis不再难懂(二)
  6. java封装概念_Java面向对象----封装概念
  7. 单进程程序怎样在linux运行,linux下C程序:运行单个实例
  8. DevOps看起来很美,实现起来却很难?
  9. UGUI实现摇杆(模仿太极熊猫)
  10. SAP安装前应准备的事项
  11. 【2022年】浙江省专升本数学全面总结-(空间解析几何与向量代数)
  12. yate--sip server的学习过程
  13. vxe-input vue 日期选择组件带农历节日、小圆点提醒
  14. Linux下使用aMsn详解(转)
  15. 路在何方?前途迷茫,去不去HP?
  16. 如何做超级链接?如何做网页链接
  17. compare用法示例•选项摘要
  18. 发帖添加作者水印插件无法发帖问题-缺少GD库支持,php如何安装gd库-一颗优雅草科技伊凡
  19. 在线客服系统源码-在线客服php源码下载-新版网站客服系统-搭建教程-无限坐席
  20. 集美大学c语言大作业,2019年集美大学硕士研究生考试初试自命题考试大纲C语言程序设计函数程序设计,20%(30分)...

热门文章

  1. unlock-music-desktop解锁加密音乐桌面版
  2. 惠普179fnw打印机使用说明_|惠普HP Color Laser MFP 179fnw一体机驱动下载v1.10官方版 - 欧普软件下载...
  3. Excel对比不同Sheet的关键词个数匹配(VLOOKUP的应用)
  4. 分数阶灰色模型的python实现
  5. MD5碰撞,不同的原始数据,MD5后,值一样,出现碰撞
  6. 【力扣】合并两个有序链表
  7. js实现斗地主的算法 验证牌型 找大于上家的牌型
  8. 项目管理手记(七)--DRP系统的文化输出与营销
  9. FW:一位软件工程师的6年总结
  10. js 字符串常用方法 切割 搜索 验证 替换