mysql中You can't specify target table <tbl> for update in FROM clause错误

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

update B set end_time =
(select start_time from B where id ="7777777jjjjjj") where id ="7777777jjjjjj"

这样写:

  

update B set end_time =
(select A.start_time from
(select start_time from B where id ="7777777jjjjjj")as A

)

 where id ="7777777jjjjjj"

原文地址:https://www.cnblogs.com/skyball/p/5818210.html