How to select the most recent set of dated records from a mysql table

后端 未结 7 1577
我在风中等你
我在风中等你 2020-11-29 01:00

I am storing the response to various rpc calls in a mysql table with the following fields:

Table: rpc_responses

timestamp   (date)
method      (varchar)
id          


        
相关标签:
7条回答
  • 2020-11-29 01:33

    The concept of "most recent" is fairly vague. If you mean something like the 100 most recent rows then you can just add a TOP(100) to your SELECT clause.

    If you mean the "most recent" based on a the most recent date then you can just do

    SELECT timestamp,method,id,response 
    FROM rpc_responses
    HAVING max(timestamp) = timestamp 
    
    0 讨论(0)
提交回复
热议问题