How to select records of the most recent date with MySQL?

3

I have table1 with the following records:

campo1    campo2     campo3

Adrian      25       2016-09-17
Juan        27       2016-09-14
Alex        23       2016-09-03
Ana         31       2016-09-17
Rocio       29       2016-09-17

In the event that the field3 is always modified but not all the records at the same time as I can get only the records that have the most recent date, try doing it with max ()

Select * from tabla1 where campo3 = max(campo3);

In this case I want to get the following result:

campo1    campo2     campo3

Adrian      25       2016-09-17
Ana         31       2016-09-17
Rocio       29       2016-09-17

but again I repeat that date is not going to stay fixed is always going to modify why try to get the most recent date with max (), and try to group and nothing, if they are so kind to explain to me that I am failing or what would be the logic that applies

    
asked by El Cóndor 20.09.2016 в 03:38
source

2 answers

3
Select * from tabla1
WHERE campo3  = (
    SELECT MAX(campo3)
    FROM tabla1
)
    
answered by 20.09.2016 / 03:49
source
3

The query would be in this way:

SELECT * from tabla1
WHERE campo3  = (
    SELECT MAX (campo3)
    FROM tabla1
)
    
answered by 20.09.2016 в 03:54