I have the following tables on my MYSQL database:
USERS
ID | login
---------------
1 | user1
2 | user2
3 | user3
STATUS
ID | userID | date | status
1 | 1 | 2018-05-10 10:00:00 | a
2 | 2 | 2018-05-15 10:00:00 | a
3 | 3 | 2018-05-20 10:00:00 | a
4 | 3 | 2018-05-20 11:00:00 | d
5 | 1 | 2018-05-15 11:00:00 | d
6 | 3 | 2018-05-25 10:00:00 | a
How do I query the STATUS
table to get only the rows with the most recent date
and where the column status
is equal to a
with no repeated userID
?
These are the lines that I want my query to return in this case:
userID | date | status
2 | 2018-05-15 10:00:00 | a
3 | 2018-05-25 10:00:00 | a