Mysql in PHP - how to update only one row in table but with greatest id number

前端 未结 9 2036

I am trying to update fields in my DB, but got stuck with such a simple problem: I want to update just one row in the table with the biggest id number. I would do something like

9条回答
  •  死守一世寂寞
    2021-02-19 03:53

    The use of MAX() is not possible at this position. But you can do this:

    UPDATE table SET name='test_name' ORDER BY id DESC LIMIT 1;
    

提交回复
热议问题