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这个表(在同一语句中)。
例:DELETE from sys_org_relation where pOrgid in (
select porgId from sys_org_relation r where r.corgid='客户id' and relationType=1112
) and and relationType=1213;
该语句中要操作的sys_org_relation 表条件也是来自sys_org_relation 表查询的结果,此时会抛出 You can't specify target table 'sys_org_relation' for update in FROM clause异常
解决办法:
需要一个中间转换的表,也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和oracle不会出现此问题。
应改为以下:
DELETE from sys_org_relation where pOrgid in (
select a.corgidfrom (
select corgidfrom sys_org_relation r where r.porgid='客户id' and relationType=1112
) a
) and and relationType=1213;
mysql You can't specify target table 'sys_org_relation' for update in FROM clause 删除表条件不能直接包含该表的更多相关文章
- mysql You can't specify target table 'sys_right_menu' for update in FROM clause (不能从Objor子句中指定目标表“SysRyType菜单)
错误语句: DELETE from sys_right_menu where right_id in (SELECT m.right_id from sys_right_menu mLEFT JO ...
- Mysql -- You can't specify target table 'address' for update in FROM clause
做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要select出用户id然后update 原语句 update address set isdeafult = 0 wh ...
- mysql You can't specify target table 'xxx' for update in FROM clause的解决
DELETE from sp_goodscontent where goodsId in (SELECT t.goodsId from ( SELECT goodsId FROM sp_goodsco ...
- mysql You can't specify target table 'xxx' for update in FROM clause
含义:您不能在子句中为更新指定目标表'xxx'. 错误描述:删除语句中直接含select,如下: DELETE FROM meriadianannotation WHERE SeriesID IN ( ...
- Mysql You can't specify target table 'newsalrecord' for update in FROM clause
这个问题是不能先select出同一表中的某些值,再update这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值.解决办法就是建立个临时的表.
- mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...
- 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中执行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 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug
不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...
随机推荐
- Linux 常用命令五 软链接和硬链接
一.软链接 相当于windows的快捷方式,当源文件不存在时,软链接失效. 创建软链接: wang@wang:~/workpalce/python$ ls -l 总用量 -rw-rw-r-- wang ...
- bzoj 2660: [Beijing wc2012]最多的方案【dp】
有点神奇的dp 首先注意到任意一个数都能被表示成若干个斐波那契数的和的形式 先求出n可以字典序最大的表示 设f[i][0/1]表示第i个斐波那契数选或者不选 如果当前数不选,那就选比他小的两个数,否则 ...
- poj 1815 Friendship【最小割】
网络流的题总是出各种奇怪的错啊--没写过邻接表版的dinic,然后bfs扫到t点不直接return 1就会TTTTTLE-- 题目中的操作是"去掉人",很容易想到拆点,套路一般是( ...
- Java之简单的四则运算
简单的四则运算 请你编写程序实现能处理两个数的+.-.*./.%的表达式程序.数据的输入/输出全部使用标准输入/输出,输入数据的第一行为你需要计算表达式的个数,从第2行开始,每一行为你计算的一个表达式 ...
- Manven下载
1.下载地址:http://maven.apache.org/download.cgi 2.点击下载链接 3.解压zip到安装路径 我的:C:\Progr ...
- _bzoj2243 [SDOI2011]染色【树链剖分】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2243 裸的树链剖分,最开始我保存一个线段树节点的color值时(若有多种颜色则为-1),不小 ...
- C#关于html颜色值的转化 ColorTranslator
//颜色转换非常重要快速的转换类. ColorTranslator.FromHtml (); //从html字符串得到颜色 ColorTranslator.ToHtml();
- 数组声明的几种方式以及length属性
声明一: int[] arr=new int[10]; for(int i=0;i<arr.length;i++){ arr[i]=i; } 声明二: int[] arr2={1,2,3}; 声 ...
- 配置maven环境变量cmd控制台提示:mvn不是内部或外部命令,也不是可运行的程序或批处理文件
配置maven环境变量cmd控制台提示:mvn不是内部或外部命令,也不是可运行的程序或批处理文件 首先maven环境变量: 变量名:MAVEN_HOME 变量值:E:\apache-maven-3.2 ...
- SQLServer 2012 高效分页
SQLSERVER2012 出新分页功能啦!!!近两天我在自己工作机的PC(没有并发,单一线程)上做了SqlServer 2000/ (2005/2008)/2012三个版本下的分页性能比较. 大致 ...