-1

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`)
Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

1

Use ORDER BY and LIMIT.

UPDATE `chatMessages` 
SET send = 'true' 
ORDER BY id DESC
LIMIT 1
Barmar
  • 741,623
  • 53
  • 500
  • 612