MYSQL update with WHERE SELECT subquery error

后端 未结 4 1311
时光取名叫无心
时光取名叫无心 2020-12-05 02:46

I have an issue with getting select sub-queries to work on an UPDATE. I\'m trying something like the following:

UPDATE foo
   SET bar=bar-1
 WHE         


        
4条回答
  •  没有蜡笔的小新
    2020-12-05 03:19

    So far as I know, when updating a table, Mysql locks it in order to do a safe update. You cannot select data and update the same table as you're trying.

    Those texts should help you

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

    • http://verysimple.com/2011/03/30/mysql-cant-specify-target-table-for-update-in-from-clause/

提交回复
热议问题