sql: update product set price = (select max(price+1) p from product) where id=1;
报错:[Err] 1093 - You can't specify target table 'product' for update in FROM clause
解释:MySQL中不允许先select出同一表中的某些值,再update这个表(在同一语句中)
解决方案:
update product INNER JOIN (select max(price+1) pc from product) p set price=p.pc where id=1;
亲测成功~~~