在update 中的 where 子句中使用子查询:

UPDATE mg_page_log as a  SET  page_num=1 WHERE id in( SELECT id  from mg_page_log WHERE id < 100 GROUP BY visit_id)

会报:

You can't specify target table 'a' for update in FROM clause 错误

所以正确的是:

UPDATE mg_page_log as a ,( SELECT id  from mg_page_log WHERE id < 100 GROUP BY visit_id)as b SET  page_num=1 WHERE a.id = b.id

相关文章:

  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2022-03-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-01-18
  • 2021-08-09
相关资源
相似解决方案