Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想更新最新的数据,或者最高的ID。
MAX 功能似乎不适用于更新。
编辑:
UPDATE table SET name='test_name' ORDER BY id DESC LIMIT 1;
似乎工作。但我不确定它是否真的是解决方案。
试试这个:
UPDATE table SET field = yourvalue WHERE Id = (SELECT MAX(Id) FROM table)
你在寻找LAST_INSERT_ID()
LAST_INSERT_ID()
Update table SET name='test_name' where id = LAST_INSERT_ID()