MySQL - Select the last inserted row easiest way

后端 未结 9 1881
误落风尘
误落风尘 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:19

    It would be best to have a TIMESTAMP column that defaults to CURRENT_TIMESTAMP .. it is the only true predictive behavior you can find here.

    The second-best thing you can do is ORDER BY ID DESC LIMIT 1 and hope the newest ID is the largest value.

提交回复
热议问题