I'm trying to construct a MySQL query that will UPDATE a row in my table WHERE the id is highest AND a field called idSession is equal to 65. It looks like this:
UPDATE `History`
SET `state` = 0
WHERE `id` = (SELECT MAX(id) FROM `History` WHERE `idSession` = 65);
And I'm getting the error message:
"Error Code: 1093. You can't specify target table 'History' for update in FROM clause".
Anyone know what's wrong with my syntax?