mySQL Update value using a max date
database, mysql, sql
Solution
This is because your UPDATE could be cycling.
Use this code instead of :
UPDATE motor
SET exec = 1
WHERE exec = 0
ORDER BY time DESC
LIMIT 1;
Problem
I have this query, I want to be able to update the exec value to TRUE when my program finishes to execute a request and save it to my database to use it as a queue for when I have multiple executions, however, whenever I try with this query it gives me an error. ``` UPDATE motor SET exec=1 where time=(SELECT max(time) FROM motor WHERE exec=0); ``` Error: ERROR 1093 (HY000): You can't specify target table 'motor' for update in FROM clause How can I do this?