This is an imitation of MySQL. There are two ways around this (actually three, but I don't like the third).
1) Since the request:
SELECT MAX(id) FROM History WHERE idSession = 65
gives the same results as:
SELECT id FROM History WHERE idSession = 65 ORDER BY id DESC LIMIT 1
you can use the solution provided by @xdazz and @Kolink by modifying the update to use the (native XML) ORDER BY syntax in the UPDATE .
2) The second way is to join your table with the above subquery. This works in more complex conditions / subqueries / joins that cannot be rewritten using the simple By order:
UPDATE History AS h JOIN ( SELECT MAX(id) AS max_id FROM History WHERE idSession = 65 ) AS m ON m.max_id = h.id SET h.state = 0 ;
source share