mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)

例如

delete from table名称 where idStr in
(
  select h.idStr from table名称 h  
  
group by h.otherKey  
  
having count(1) >1
);

 

就会报上面的错误

delete from table名称 where idStr in
(
    select s.idStr from (
    select h.idStr, h.otherKey,count(1) c from table名称 h     group by h.otherKey   ) s where s.c >1 );

 

通过中间临时表来执行即可解决问题

 

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2021-07-01
  • 2021-11-07
  • 2021-06-28
  • 2021-10-24
  • 2021-05-20
  • 2022-01-12
猜你喜欢
  • 2021-10-24
  • 2022-12-23
  • 2021-06-02
  • 2022-01-21
相关资源
相似解决方案