Answer the question
In order to leave comments, you need to log in
How to select the maximum date in MYSQL with one select?
There is a table in which there is a field type datetime and timestamp. I need to select the maximum time (datetime type) value. I write: select info, MAX(date) from table
It gives me the maximum date, everything is OK, but the value of info is from the first line in the result of the selection.
The design works correctly:
Select * from table where date IN (SELECT MAX(`date`) as `time` FROM `table`)
Answer the question
In order to leave comments, you need to log in
you understand correctly: if you need to get all the records with the maximum date, then you can’t do without a subquery.
PS Your question is at odds with the code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question