[Err] 1093 - You can't specify target table 'master_data' for update in FROM clause
delete from master_data where category_id not in (
select category_id from master_data a, bc_category b where a.category_id=b.cate_id
)
执行SQL语句时出现这个错误。原因是在更新这个表和数据时又查询了它,而查询的数据又做了更新的条件。以前ORACLE上面没有这个错误。
上面这个语句其实没有写好 不优化了
直接更新
delete from master_data where category_id not in(select category_id from (
select category_id from master_data a, bc_category b where a.category_id=b.cate_id
) tmp);
注:将查询出来的数据做一个第三方表进行管理
[Err] 1093 - You can't specify target table 'master_data' for update in FROM clause的更多相关文章
- Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause
Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...
- [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 ...
- 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug
不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...
- MySQL: [Err] 1093 - You can't specify target table 'bk' for update in FROM clause
错误的意思说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in ( select ...
- MySQL 1093 - You can't specify target table 'sc' for update in FROM clause
错误代码如下: #(8) 把"邓维杰"同学的成绩全部删除. SELECT * FROM sc WHERE EXISTS(SELECT * FROM student WHERE st ...
- MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause
MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...
- 1093 - You can't specify target table 'account' for update in FROM clause
目的:查询一张表的相同的两条数据,并删除一条数据. 分析 先查询出相同的数据,然后删除 查询相同的数据 SELECT a.id FROM account a GROUP BY a.username H ...
- django.db.utils.OperationalError: (1093, "You can't specify target table 'xxx' for update in FROM clause")
这个错误的意思是,不能在update某张表的where条件中,再次select这张表的某些值作为筛选条件,比如: update message set content = "hello&qu ...
- MySQL - 1093异常 - You can't specify target table 't' for update in FROM clause
有一个表示地区的表,表结构与数据大概如下表. ID NAME PARENT_ID 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3 7 小谷围街道 6 现为了查 ...
随机推荐
- linux执行jmeter脚本解决响应数据为空
Linux服务器用命令执行了jmeter脚本,在本地查看结果时发现结果树种的“请求.响应数据”都显示为空,有错误日志中也看不出所以然,请看演示! 1 ,先执行脚本:执行成功(...end of run ...
- pytest使用简介
pytest是基于py unittest的一个单元测试框架,用起来比unittest简单不少,不过和unittest使用不太一样,总结如下: 格式: case的py文件名必须是test开头 def用例 ...
- 父级POM的表现形式
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- image management in kubernet
Image How can I edit an existing docker image metadata? docker-copyedit Registry Disk kubevirtis a g ...
- markdown code test - markdown code test - markdown code test - markdown code test
目录 主要代码 bottom cc 主要代码 <div class="tocCol1 js-toc"></div> <a>bc</a> ...
- Celery完成定时任务
1.什么是Celery Celery是一个简单.灵活且可靠的,处理大量消息的分布式系统 专注于实时处理的异步任务队列 同时也支持任务调度 celery支持linux,如果windows使用celery ...
- Bigger-Mai 养成计划,前端基础学习之CSS
在标签上设置style属性: background-color: #2459a2; height: 48px; ... 编写css样式: 1. 标签的style属性 2. 写在head里面 style ...
- 关于PHP5.6连接SqlServer
在做一个PHP报名系统的时候需要使用mssql来和winform结合起来使用, 但是发现我的php环境没有sqlsrv模块,于是乎,我就开始百度了 找到了微软官方下载地址,对照php版本,下载对应的模 ...
- jQuery Validate和Thymeleaf相关
jQuery Validate https://www.cnblogs.com/liuhongfeng/p/5135676.html https://www.cnblogs.com/linjiqin/ ...
- wireshark基础学习—第一部分wireshark的基础知识
1.Wireshark主窗口 Wireshark的主窗口如下所示 2.每个面板的内容 Packet List(数据包列表): 最上面的面板用表格显示了当前不惑文件中的所有数据包,其中包括了数据包序号. ...