The Query:
UPDATE nominees SET votes = ( SELECT votes
FROM nominees
WHERE ID =1 ) +1
The Error:
You can’t specify target table ‘nominees’ for update in FROM
Not sure whats wrong there based on the error, this is the first time im tryin to incriment a column inline i guess you can call it. So I am obvioulsy doing something wrong but dont know how to fix it.
Your
UPDATEquery is missing anyWHEREclause so even if MySQL had allowed it then the effect would be to find thevotesvalue for theID =1row add 1 to it then update all rows in the table with the result.I suspect that was not the desired behaviour. To increment the column value you just need to do
Just in case you do want the other behaviour you would need to do
This wrapping into a derived table avoids the
You can't specify target table 'nominees' for update in FROMerror you were getting.