繁体   English   中英

从DateTime排序的MySQL表中获取用户的最后一个条目

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

我有一张桌子,看起来像这样:

USERNAME    DATA   DATETIME
Jhon        text1  2010-06-01 16:29:43
Mike        text2  2010-06-01 16:29:22
Silver      text3  2010-05-23 06:19:12
Jhon        text1  2010-02-01 01:02:00

如果我想要JhonLAST条目中的数据 ,该php命令是什么? 谢谢!

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

“ datetime desc排序”和“ limit 1”配对将为您提供最后的输入。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM