含义:您不能在子句中为更新指定目标表'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 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…
问题: 今天在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这个表. 解决方法: 需…
做地址管理时,需要先根据要设为默认的地址的用户将用户的其他地址都设置为非默认 需要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…
这个错误的意思是,不能在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操作的就不是同一张实体…
错误语句: 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…
这个问题是不能先select出同一表中的某些值,再update这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值.解决办法就是建立个临时的表.…