mysql You can't specify target table for update in FROM clause解决方法
出现这个错误的原因是不能在同一个sql语句中,先select同一个表的某些值,然后再update这个表。

<pre>
mysql> update message set content='Hello World' where id in(select min(id) from message group by uid);
ERROR 1093 (HY000): You can't specify target table 'message' for update in FROM clause
</pre>

因为在同一个sql语句中,先select出message表中每个用户消息的最小id值,然后再更新message表,因此会出现 ERROR 1093 (HY000): You can’t specify target table ‘message’ for update in FROM clause 这个错误。

解决方法:select的结果再通过一个中间表select多一次,就可以避免这个错误
<pre>
update message set content='Hello World' where id in( select min_id from ( select min(id) as min_id from message group by uid) as a );
</pre>

最新文章

  1. poj 1572
  2. macOSX 访问 win7共享文件
  3. Delphi开发的IP地址修改工具
  4. VNC+SSH相关应用
  5. 关于sources.list和apt-get [转载]
  6. (原创)LAMP教程2-安装虚拟机软件VirtualBox
  7. Python之路,Day4 - Python基础4 (new版)
  8. android 再按一次退出程序(实现代码)
  9. 【转】char *str 和 char str[]的区别
  10. 积累的VC编程小技巧之属性页
  11. Bug记录:微博的Java SDK返回经纬度错误
  12. PDO详解
  13. word建立统一的表格样式
  14. RSA加解密实现
  15. 20170310 - Python 3 下 SQLAlchemy 的 MySQL 数据库 URI 配置
  16. Android-PickerView【仿iOS的PickerView控件,并封装了时间选择和选项选择这两种选择器】使用
  17. JavaScript 作用域、命名空间及闭包
  18. faster rcnn
  19. Helm: Error: no available release name found
  20. Docker(十三)-Docker save and load镜像保存

热门文章

  1. Poj 1743 Musical Theme(后缀数组+二分答案)
  2. Linux下多线程模拟停车场停车
  3. Large Kernel Matters —— Improve Semantic Segmentation by Global Convolutional Network(GCN全局卷积网络)
  4. 2018-2019-2 网络对抗技术 20165322 Exp9 Web安全基础
  5. ubuntu之路——day7.2 regularization
  6. python 图形
  7. file_get_contents(&quot;php://input&quot;)
  8. The Matrix | 黑客帝国
  9. iis网站搭建http访问的文件服务器
  10. Java 8 新特性总结