问题: 今天在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这个表. 解决方法: 需…
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 查询,需要改成中间临时表再查询…
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( * ) > ) 报错…
不同于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…
含义:您不能在子句中为更新指定目标表'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…
这个错误的意思是,不能在update某张表的where条件中,再次select这张表的某些值作为筛选条件,比如: update message set content = "hello" where id in (select min(id) from message group by uid) 修改sql语句的解决方法是: 通过 select * from message 创建一个message的临时表,这样,update与select min(id) from操作的就不是同一张实体…
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…
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 错…
项目中有一个功能变动上线,其中有一张表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…
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+| id | value |+----+------------------------------------+| 3 | 3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 4 | 4aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || 5 | 5aaaaaaa…