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
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/