MySQL: Get most recent record

后端 未结 7 1757
情歌与酒
情歌与酒 2020-11-28 20:42

In the table below, how do I get just the most recent record of id=1 based on the signin column and not all 3 records?

+----+--         


        
7条回答
  •  广开言路
    2020-11-28 21:17

    Simple Way To Achieve

    I know it's an old question You can also do something like

    SELECT * FROM Table WHERE id=1 ORDER BY signin DESC
    

    In above, query the first record will be the most recent record.

    For only one record you can use something like

    SELECT top(1) * FROM Table WHERE id=1 ORDER BY signin DESC
    

    Above query will only return one latest record.

    Cheers!

提交回复
热议问题