set price = (select price from apples where variety = 'gala')
where variety = 'fuji';
錯誤提示是:ERROR 1093 (HY000): You can't specify target table 'apples' for update in FROM clause. MySQL手冊UPDATE documentation這下面有說明 : 「Currently, you cannot update a table and select from the same table in a subquery.」 在這個例子中,要解決問題也十分簡單,但有時候不得不經過查詢子句來update目標。好在咱們有辦法。