读书人

sql更新数据不能有from的异常解决方案

发布时间: 2012-07-22 19:31:17 作者: rapoo

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 affectedRows 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 Server

热点推荐