这个错误是说从t表select出来的无法又更新t表. 可以在select的时候先取个别名,弄个临时表即可.…
数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用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…
有一个表示地区的表,表结构与数据大概如下表. 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…
问题 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…
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…
错误的意思说,不能先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…
做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要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 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…
You can't specify target table 'sc' for update in FROM clause 背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面的sql是我写的,执行就报这个错,这个原因说的是 不能从自己表里查数据再更新自己 解决方法:嵌套一层中间表 update sc set sc.score = (select t1.score from (select avg(sc1.score) score from sc sc1 where sc…
不同于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…
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+| id | value |+----+------------------------------------+| 3 | 3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 4 | 4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 5 | 5aaaaaaa…
关键词: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='邓维杰')); 报错:…
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 错…
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…
今天在操作数据库的时候遇到了一个问题,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…
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这个表. 解决方法: 需…
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…
有时候我们在编辑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') );…
[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…
目录 #事故现场 #解决方法 #事故现场 mysql执行update操作报错: sql如下: update psmp.Users set name='Jack' where name='Lily'; 报错如下: Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, t…
mysql数据库在执行同时查询本表数据并删除本表数据时候,报错! 报错原因: DELETE from sys_user_function where User_Id = 19 and Function_Id in ( select s.Function_Id from sys_user_function s where s.User_Id=19 ) 修改如下: delete from sys_user_function where User_Id = 19 AND Function_Id in…
当我运行一条联合查询的sql语句时报如下错误: [Err] 1248 - Every derived table must have its own alias,大概意思是每一张派生表必须要有自己的别名.这里加上别名即可. 原先sql: select * from t_test t1 where t1.content like '%test%' Union all select * from (select * from t_test t2 where t2.content not like '…
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 = '…
出现这个问题的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有待升级.…