MySQL #1093 - You can't specify target table 'giveaways' for update in FROM clause

前端 未结 6 991
小蘑菇
小蘑菇 2020-11-28 12:09

I tried:

UPDATE giveaways SET winner = \'1\' WHERE ID = (SELECT MAX(ID) FROM giveaways)

But it gives:

#1093 - Yo

6条回答
  •  清酒与你
    2020-11-28 12:39

    You can create a view of the subquery first and update/delete selecting from the view instead.. Just remember to drop the view after.

提交回复
热议问题