简体   繁体   中英

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  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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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