I’m starting in Mysql and I’m trying to find a way to select the maximum id inside update. This is what I tried but it doesn’t work.
UPDATE `chatMessages` SET send = 'true' WHERE id = (SELECT MAX(id) FROM `chatMessages`)
Advertisement
Answer
Use ORDER BY
and LIMIT
.
UPDATE `chatMessages` SET send = 'true' ORDER BY id DESC LIMIT 1