sql更新数据不能有from的错误解决方案

You can't specify target table 'tbl_total_log' for update in FROM clause


update tbl_total_log set unassigned = unassigned - 199 where id = (select id from (select max(id) id from tbl_total_log) tbl_temp);

Query OK, 1 row affected
Rows matched: 1  Changed: 1  Warnings: 0


select * from tbl_total_log
 where id = (select id from (select max(id) id from tbl_total_log) tbl_temp);

1 row in set



http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/

你可能感兴趣的:(sql,更新,数据)