开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜