UPDATE forms SET
pos = (SELECT MIN(pos)-1 FROM forms)
WHERE id=$id
This doesn\'t work, error message:
**You can\'t specify target
Your problem is stated plainly in the MySQL manual:
Currently, you cannot update a table and select from the same table in a subquery.
You'll want to use a transaction. Turn AutoCommit off, begin a transaction, then do a SELECT MIN(pos)-1 FROM forms FOR UPDATE, take that result, do the update with it, then commit your transaction.