Getting the last entry of a user from a MySQL table ordered by DateTime

后端 未结 1 504
暗喜
暗喜 2021-01-27 20:31

I have a table who looks something like this:

USERNAME    DATA   DATETIME
Jhon        text1  2010-06-01 16:29:43
Mike        text2  2010-06-01 16:29:22
Silver            


        
1条回答
  •  生来不讨喜
    2021-01-27 21:30

    SELECT data FROM table WHERE username = 'Jhon' ORDER BY datetime DESC LIMIT 1

    The "order by datetime desc" paired with "limit 1" gets you his last entry.

    0 讨论(0)
提交回复
热议问题