mysql中【update/Delete】update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update in FROM clause.
关键词:mysql update,mysql delete
update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update in FROM clause.
情况如下:
(1)第1行更新语句中,update表与子查询中表一样,所以报错
(2)第2行更新语句中,update表与子查询中表不一样,所以可以执行。
如何解决?
把子查询换成join即可。
例如:
总结:
(1)在update与delete中,都不能再以子查询的方式调用其表本身(因为一致性的关系),否则会报错。
(2)但可以以派生表的方式 join 使用
mysql中【update/Delete】update中无法用基于被更新表的子查询,You can't specify target table 'test1' for update in FROM clause.的更多相关文章
- mysql更新表数据时报错 You can't specify target table 'RES_CATALOG_CLASSIFY' for update in FROM clause
You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 将sql语句 UPDATE RES ...
- mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM clause
数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用sql语句来实现.原来以为简单的 update table a set a.字段a=(select b字段 from t ...
- mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...
- 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 ...
- mysql You can't specify target table 'sys_org_relation' for update in FROM clause 删除表条件不能直接包含该表
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...
- 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 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 ...
- 关于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 - 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 现为了查 ...
随机推荐
- 2019 ACM/ICPC 全国邀请赛(西安)J And And And (树DP+贡献计算)
Then n - 1n−1 lines follow. ii-th line contains two integers f_{a_i}(1 \le f_{a_i} < i)fai(1≤fa ...
- tf Dataset API
https://zhuanlan.zhihu.com/p/30751039 https://zhuanlan.zhihu.com/p/37106443 关于其中shuffle时的buffer_size ...
- 【学习】022 ActiveMQ
一.消息中间件概述 1.1消息中间件产生的背景 在客户端与服务器进行通讯时.客户端调用后,必须等待服务对象完成处理返回结果才能继续执行. 客户与服务器对象的生命周期紧密耦合,客户进程和服务对象进程都 ...
- vue2.0 之 过渡动画transtion
过渡的类名: 在进入/离开的过渡中,会有 6 个 class 切换 (v 是前缀,name = v) v-enter:定义进入过渡的开始状态.在元素被插入时生效,在下一个帧移除. v-enter-ac ...
- CSS3之mix-blend-mode
<!-- more --> 在线编辑demo 属性描述了元素的内容应该与元素的直系父元素的内容和元素的背景如何混合. mix-blend-mode: normal; //正常 mix-bl ...
- springcloud 配置actuator
pom.xml <!--Spring Boot Actuator,感应服务端变化--> <dependency> <groupId>org.springframew ...
- Java语言Lang包下常用的工具类介绍_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 无论你在开发哪中 Java 应用程序,都免不了要写很多工具类/工具函数.你可知道,有很多现成的工具类可用,并且代码质量都 ...
- 使用IDEA自动生成Java实体类
在上一篇帖子里,我们已经通过idea连接上了数据库,这里,通过IDEA自带的功能来根据数据库字段生成POJO 1. 选中一张表,右键--->Scripted Extensions--->选 ...
- BZOJ 3043: IncDec Sequence 差分 + 思维
Code: #include <bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) ...
- HDU-6709 Fishing Master
Description Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As every ...