How to get latest ID number in a table?

后端 未结 7 1865
日久生厌
日久生厌 2021-01-22 00:58

How can I get the latest ID in a table?

7条回答
  •  一生所求
    2021-01-22 01:30

    If there are no inserts being done on a table, then SELECT MAX(ID) should be fine. However, every database has a built-in function to return the most recently created primary key of a table after an insert has been performed. If that's what you're after, don't use MAX().

    http://www.iknowkungfoo.com/blog/index.cfm/2008/6/1/Please-stop-using-SELECT-MAX-id

提交回复
热议问题