问题
I would like to know if this is possible using a mysql query:
I have a table called updates.
In the updates table I have 2 columns, id
and timestamp
.
I have 5 rows each with the same id
but with different date timestamps. An example of this timestamp would be the value: 2012-08-04 23:14:09
.
I would like to select only the most recent timestamp value out of the 5 results. This could also be explained by saying that I would like to select the value that is closest to the current date and time. How could I do this?
回答1:
SELECT id, timestamp FROM updates ORDER BY timestamp DESC LIMIT 1
回答2:
have you tried SELECT MAX(timestamp)
?
来源:https://stackoverflow.com/questions/11812215/mysql-select-most-recent-date-out-of-a-set-of-several-possible-timestamps