MySQL Select the most recent date from a set of several possible timestamps?

I would like to know if this is possible with a mysql query:

I have a table with the name of updates.

In the update table, I have 2 columns, id and timestamp .

I have 5 lines with the same id , but with different time dates. An example of this timestamp would be: 2012-08-04 23:14:09 .

I would like to select only the most recent timestamp value from 5 results. This can also be explained by the fact that I would like to choose a value that is closest to the current date and time. How can i do this?

+6
source share
2 answers
 SELECT id, timestamp FROM updates ORDER BY timestamp DESC LIMIT 1 
+19
source

Have you tried SELECT MAX(timestamp) ?

+10
source

Source: https://habr.com/ru/post/922130/


All Articles