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) ; 本地 ...
随机推荐
- 重启fpm
ps aux | grep php-fpm cat /etc/php-fpm.conf kill -USR2 `cat /run/php-fpm/php-fpm.pid
- bzoj 3555: [Ctsc2014]企鹅QQ【hash+瞎搞】
首先注意 先hash一下,双hash,然后枚举删去位置,把hash值排个序,把些相等的加起来统计一下对数即可 #include<iostream> #include<cstdio&g ...
- poj 3130 How I Mathematician Wonder What You Are! 【半平面交】
求多边形的核,直接把所有边求半平面交判断有无即可 #include<iostream> #include<cstdio> #include<algorithm> # ...
- Unix\Linux | 总结笔记 |文件系统
1. ls [选项] [文件] 显示目录中的文件信息 -a 显示全部文件(包括隐藏文件) -l 查看文件的属性.大小等详细信息 (ls -l 详解) -al 查看当前目录中 ...
- python包管理工具他们之间的关系
python包管理工具之间的关系 现在的python包管理工具有很多,非常混乱,必须理清他们之间的关系才能更好的使用python构建强大的包关系系统工具. 首先:python官方推荐的第三方库是PyP ...
- bzoj2002 [Hnoi2010]Bounce 弹飞绵羊【LCT】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2002 第一道LCT,调了3天,发现是智障bug,我的青春... 主要参考了黄学长的代码,也没 ...
- Triangular Pastures POJ - 1948
Triangular Pastures POJ - 1948 sum表示木条的总长.a[i]表示第i根木条长度.ans[i][j][k]表示用前i条木条,摆成两条长度分别为j和k的边是否可能. 那么a ...
- UnixTime的时间戳的转换
public static string XConvertDateTime(double unixTime) { System.DateTime time = System.DateTime.MinV ...
- "码代码"微信号今日上线,为互联网同仁提供最前沿咨询
"码代码"微信号今日上线 关注即有好礼相送 三月,春意浓浓的日子,三月,属于女人的日子,而今天...... “2014年天空成人放送大赏”于5日晚举办颁奖典礼,“年度最佳AV女优” ...
- greenplum4.3.8.2安装
GREENPLUM总体结构: 数据库由Master Severs和Segment Severs通过Interconnect互联组成. Master主机负责:建立与客户端的连接和管理:SQL的解析并 ...