博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL更新时Error Code:1093和Error Code:1175的解决办法
阅读量:4597 次
发布时间:2019-06-09

本文共 824 字,大约阅读时间需要 2 分钟。

Error Code: 1093. You can't specify target table 'ws_product' for update in FROM clause

这个是我们在使用update或者delete语句时,在where条件里面加入的子查询导致的。例如如下的update语句:

update table set type = 'static' where id in (

select id from ws_product where first_name ='superman'
);

修改上述语句为下面这样,该问题可以解决:

update ws_product set type = 'static' where id in (

select id form (
 select id from ws_product where first_name ='superman'
) xx
);

注意,这样一定要给最里面的子查询定义一个别名,不然会报另外一个错误:

Error Code: 1248. Every derived table must have its own alias

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.

解决办法是在当前session下执行如下的语句

SET SQL_SAFE_UPDATES = 0;

然后再执行Update语句

 

转载于:https://www.cnblogs.com/pangblog/p/3260705.html

你可能感兴趣的文章
排序算法
查看>>
屏幕滑动与滚动条事件进行绑定
查看>>
js清除浏览器缓存的几种方法
查看>>
hdu 3127(矩阵切割)
查看>>
hdu 1864(01背包)
查看>>
[stl] SGI STL的空间配置器
查看>>
【IIS】IIS中同时满足集成模式和经典模式
查看>>
使用DOM解析XML文档
查看>>
python函数参数传递总结
查看>>
java生成Https证书,及证书导入的步骤和过程
查看>>
iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
查看>>
LeetCode 661. Image Smoother
查看>>
(译文)MVC通用仓储类
查看>>
《操作系统》第5章:输入/输出(I/O)管理
查看>>
Python初探第一篇-变量与基本数据类型
查看>>
快速创建SpringBoot2.x应用之工具类自动创建web应用、SpringBoot2.x的依赖默认Maven版本...
查看>>
《剑指offer》字符串中的字符替换
查看>>
PHP学习笔记(11)初探PHPcms模块开发
查看>>
【剑指Offer】44、反转单词序列
查看>>
毕业设计《项目管理》总结01
查看>>