我在 SO 上看到了一些类似类型的问题,但是,我无法找到解决我的特定问题的方法。我想获取最近的时间戳并在 PHP 代码中调用它。 (仅供引用,这些不是我的真实专栏,只是一个缩短的示例)。
我的表
row_1 row_2 TimeStamp
======================================================
01 04 2014-06-24 22:00:00
02 01 2014-06-25 19:00:00
03 93 2014-06-27 14:00:00
04 83 2014-06-27 14:31:20 <=== I would like to return this row (latest time)
所以,我想做的是能够:
1) Select the "newest" row, based on timestamp AND
2) Select the 'row_2' column accordingly to the timestamp
在这方面的任何帮助都会很棒。
感谢进阶!
最佳答案
SELECT `newest`, `user_2`
FROM `your_table`
ORDER BY `timestamp` DESC
LIMIT 1
LIMIT 1 是为了只获取一组数据。
关于php - MySQL 在 PHP 中调用最近的时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24448698/