这个问题是不能先select出同一表中的某些值,再update这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值.解决办法就是建立个临时的表.…
做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要select出用户id然后update 原语句 update address set isdeafult = 0 where user_id = (select user_id from address where id = ?) 报错 -- You can't specify target table 'address' for update in FROM clause 大意是不能先select出同一表中的某些…
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…
DELETE from sp_goodscontent where goodsId in (SELECT t.goodsId from ( SELECT goodsId FROM sp_goodscontent GROUP BY goodsId HAVING count(1)>1 ) t) 之前的sql 查询,需要改成中间临时表再查询…
含义:您不能在子句中为更新指定目标表'xxx'. 错误描述:删除语句中直接含select,如下: DELETE FROM meriadianannotation WHERE SeriesID IN ( SELECT SeriesID as tid FROM meriadianannotation GROUP BY SeriesID HAVING count(SeriesID) > 1 ) AND data NOT IN ( SELECT min(data) as bid FROM meriadi…
错误语句: DELETE from sys_right_menu where right_id  in (SELECT m.right_id from sys_right_menu  mLEFT JOIN sys_right  r on r.right_id=m.right_idWHERE r.right_id is null) 更正后: DELETE from sys_right_menu where right_id  in (SELECT right_id from (SELECT m.r…
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+| id | value |+----+------------------------------------+| 3 | 3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 4 | 4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 5 | 5aaaaaaa…
Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause 意思是不能在同一语句中更新select出的同一张表元组的属性值 解决方法:将select出的结果通过中间表再select一遍即可. 错误sql: update company_info set email = 'ttt@163.com' ) 修改后可执行的sql: update c…
MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 2017年03月21日 11:32:46 回归心灵 阅读数:686   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u010657094/article/details/64439486 当执行以下sql语句时会出现 Error Code:1093 错…
不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地测试是通过的,但是在上到测试环境的时候,发现还是会报如下错误: , notice_code ) a) ; - You can't specify target table 'teaching_department' for update in FROM clause 对比版本发现,本地是5.6.25…
有一个表示地区的表,表结构与数据大概如下表. ID NAME PARENT_ID 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3 7 小谷围街道 6 现为了查询方便,需要加一列PARENT_NAME,用以表示上级地区的名称(虽然不符合第三范式,传递依赖,但有时为了业务上的可行性.便利性,可以按实际情况考虑) ID NAME PARENT_ID PARENT_NAME 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3…
数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用sql语句来实现.原来以为简单的 update table a set a.字段a=(select b字段 from table  where id=?) ,set a.字段b=(select a字段 from table where id=?) where id=? ,结果报了 这个问题 You can't specify target table 'wms_cabinet_form' for update in…
关键词: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中,都不能再以子查询的方…
错误代码如下: #(8) 把"邓维杰"同学的成绩全部删除. SELECT * FROM sc WHERE EXISTS(SELECT * FROM student WHERE student.sno=sc.sno AND student.sname='邓维杰'); DELETE FROM sc WHERE degree IN(SELECT degree FROM sc WHERE sno=(SELECT sno FROM student WHERE sname='邓维杰')); 报错:…
今天在操作数据库的时候遇到了一个问题,sql语句如下: UPDATE cpn_yogurt_registration SET dep1Name = '1' WHERE `key` in  (SELECT `key` FROM  cpn_yogurt_registration WHERE transactionStatus = 'SUCCESS' and dep1Name  is null ) 执行之后,打印出的信息是you can't specify target  table 'cpn_yog…
问题 You can't specify target table 'user_cut_record_0413' for update in FROM clause 原因 待更新/删除的数据集与查询的数据集撞车了,可以给后面的数据集加个别名,来解决撞车问题 报错语句 delete from user_cut_record_0413 where record_id IN ( select record_id from user_cut_record_0413 GROUP BY record_id…
sql语句(update/delete都会出现此问题) update x set available_material_id = null where id not in (select id from x where additional_info = 1); mistake 大致意思是,在同一语句中,不能先select出同一表中的某些值,再update这个表. You can't specify target table 'x' for update in FROM clause mysql…
问题: 今天在MySQL数据库删除重复数据的时候遇到了一个问题.如下脚本: DELETE FROM tempA WHERE tid IN ( SELECT MAX(tid) AS tid FROM tempA GROUP BY name,age ) 会出现报错信息: You can't specify target table 'tempA' for update in FROM clause 大致意思是,在同一语句中,不能先select出同一表中的某些值,再update这个表. 解决方法: 需…
有时候我们在编辑update时需要select作为条件,在mysql中有时会出现这样的错误:You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: WHERE id in( SELECT id FROM ship_product_cat WHERE name in('Control','Propeller/Shaft') );…
MySQL执行更新语句报错: 更新语句:UPDATE test SET state=50 WHERE num IN(SELECT num FROM test WHERE state=60): 报错:ERROR 1093 (HY000): You can't specify target table 'test' for update in FROM clause 表数据: state num50 10150 10250 20160 20260 203 解决方式:同表不支持 update子查询结果…
1.执行sql语句报上面的错误: DELETE FROM db_student WHERE RowGuid IN ( SELECT RowGuid FROM db_student WHERE age = GROUP BY RowGuid HAVING count( * ) > ) AND ID NOT IN ( SELECT MAX( ID ) AS id FROM db_student WHERE age = GROUP BY RowGuid HAVING count( * ) > ) 报错…
项目中有一个功能变动上线,其中有一张表ttt的字段cc,历史数据需要处理,把字段cc中为'xxx'的值替换为'yyy'. 表A结构如下: CREATE TABLE `ttt` ( `id` bigint NOT NULL, `aa` int NOT NULL COMMENT 'xxx', `bb` int(11) NOT NULL COMMENT 'xxx', `cc` varchar(64) NOT NULL COMMENT 'xxx', ... PRIMARY KEY (`id`), UNI…
[Err] 1093 - You can't specify target table 's' for update in FROM clause 执行SQL DELETE from book WHERE id IN( SELECT id FROM ( SELECT id,name FROM book WHERE name IN( SELECT name FROM book GROUP BY name HAVING count(name) > 1 ) ) t WHERE id NOT IN (…
目的:查询一张表的相同的两条数据,并删除一条数据. 分析 先查询出相同的数据,然后删除 查询相同的数据 SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1: DELETE FROM account WHERE id = (SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1) : 1093 - You ca…
在执行sql: delete from emp where id in (select id from emp where cdate<'2018-02-02') 时报出以下异常: ### The error occurred while setting parameters ### SQL: delete from emp where id in (select id from emp where cdate<?) ### Cause: java.sql.SQLException: You…
You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据. 将sql语句 UPDATE RES_CATALOG_CLASSIFY SET CATALOG_SORT = CATALOG_SORT + 1 WHERE ID = ( SELECT ID FROM `res_catalog_classify` WHERE PARENT_ID = '001' AND CATALOG_SORT = 7…
UPDATE emp e SET e.salary=e.salary+7 WHERE e.id IN(SELECT e1.id FROM emp e1,dept d WHERE e1.dep_id=d.id AND d.name='开发一部' AND e1.salary<2000); 不能先select出同一表中的某些值,再update这个表(在同一语句中). 在mysql 中会出现这个问题. 改写: UPDATE emp e SET e.salary=e.salary+7 WHERE e.id…
UPDATE bpm_tksign_data WHERE actinstid ' AND nodeid = 'SignTask1' AND batch = ( SELECT max(a.batch) m FROM bpm_tksign_data a WHERE a.actinstid ' AND a.nodeid = 'SignTask1' ); 这种写法,mysql各个版本都不支持. UPDATE bpm_tksign_data WHERE actinstid ' AND nodeid = '…
错误的意思说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in (        select max(id) from tbl a where EXISTS        (            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1        )        group by tac…
出现这个问题的MYSQL的SQL语句形如: DELETE FROM xxxxa WHERE EXISTS (SELECT * FROM xxxx1 WHERE xxxxa.xxid=123) 解决方法,把结果放在一个临时表里: DELETE FROM xxxxa WHERE xxxxa.id IN (SELECT tmp.id FROM (SELECT * FROM xxxxaWHERE xxxxa.xxid=123)tmp);   但是oracle是可以的,说明mysql有待升级.…