在mysql中更新数据,出现You can't specify target table for update in FROM clause错误,这句话意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 updatetablesetdel_flag='2'whereid=#{id}ORdept_idIN(SELECTt.idFROMtabletWHEREfind_in_set(#{id}, ancestors) 解决方案: 再嵌套...
报错:You can't specify target table for update in FROM clause。 其含义:不能在同一表中查询的数据作为同一表的更新数据。 那么新建一个虚表 deletefromt_fileswhereidin(selectidfrom(selectidfromt_fileswherefind_in_set(id, getChildLst(1))); 报错:Every derived table must have its own alias 其含...
update student set address = (select address from student where name = '李四') where name = '张三'; 1. 2. 此时,一样的报错:> 1093 - You can’t specify target table ‘student’ for update in FROM clause 解决方式同上,查询时再加一层,使其成为临时表: update student set address = (selec...
You can't specify target table '表名' for update in FROM clause 翻译为:不能先select出同一表中的某些值,再update这个表(在同一语句中) 实例: 表:result 表result 表student 表student 表:grade 表grade 要求:给大一成绩不合格的分数加5分 思路: 第一步:查询出大一成绩不合格的成绩集合 SELECT res.Stud...
结果如下:不能先select出同一表中的某些值,再update这个表 企业微信截图_16564851387006.png 怎么处理呢,很简单,将查询结果加多一个别表名再进行查询即可,如下 DELETEFROMwork_item_role_permissionWHEREid IN(SELECTresult.id FROM(SELECTt.id FROM(SELECTt1.id,t1.permission_code,t1.work_item_role_idFROMwork...
)a ) 执行成功 原因 You can't specify target table for update in FROM clause含义:不能在同一表中查询的数据作为同一表的更新数据。 因此将select出的结果再通过中间表select一遍,这样就可以了。 发布于 2021-03-16 11:08 MySQL 赞同添加评论 分享喜欢收藏申请转载 ...
代码逻辑:先查出符合条件的数据的ID,然后再对这个id的数据进行操作,此时就会报【You can’t specify target table for update in FROM clause】 UPDATE a SET model_no = 0 WHERE id IN ( SELECT id FROM a WHERE gender = '1' AND type = '4' ...
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql: 复制代码代码如下: delete from tbl where id in ( select max(id) from tbl a where EXISTS ...
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先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 ...
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先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 ...