MySQL - Select the last inserted row easiest way

后端 未结 9 1890
误落风尘
误落风尘 2020-11-30 09:56

I simply need to select the last entered row specified by condition, e.g:

SELECT ID from bugs WHERE user=Me

I need to return only the very

9条回答
  •  野性不改
    2020-11-30 10:20

    In concurrency, the latest record may not be the record you just entered. It may better to get the latest record using the primary key.

    If it is a auto increment field, use SELECT LAST_INSERT_ID(); to get the id you just created.

提交回复
热议问题