sql语法错误[1093] You can't specify target table 'score' for update in FROM clause

发布时间 2023-04-22 18:12:40作者: myWang

不能在同一张表中将查询非结果集作为更新条件执行

将需要的结果集外层套一层自查询如

update a set a.num=a.num+1 where a.name in (select a.age from a where xx=xxx) ;
报错 [1093] You can't specify target table 'score' for update in FROM clause

  

update a set a.num=a.num+1 where a.name in (select b.age from(select a.age from a where xx=xxx)AS b)  ;

  这里的b作为别名再查一遍即可