Calculate next Primary Key - of specific format

后端 未结 3 1183
萌比男神i
萌比男神i 2020-12-21 11:58

I have a table which holds a list of IDs, and various other columns such as IDName.

The Primary Key of the table is the ID itself, however it does not auto_increment

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 12:19

    Ok, so far I've come up with, I think this will meet my requirements (unless there are any suggestions about a more optimal way to do it?)

    SELECT ID 
    FROM myTable 
    WHERE ID > 27770000 
      AND ID < 27780000 
    ORDER BY ID DESC 
    LIMIT 1
    

提交回复
热议问题