开发者

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

开发者 https://www.devze.com 2023-01-01 15:53 出处:网络
I have a table who looks something like this: USERNAMEDATADATETIME Jhontext12010-06-01 16:29:43 Miketext22010-06-01 16:29:22

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      text3 开发者_如何学Go 2010-05-23 06:19:12
Jhon        text1  2010-02-01 01:02:00

What is the php command if i want the DATA from the LAST entry made by Jhon ??? Thanks!


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

精彩评论

暂无评论...
验证码 换一张
取 消