I have two tables: Users and Files.
Users table has 10 rows, Files table has 450 rows which has a column for user ID’s (UserID).
I want to query list of all People and files they last downloaded. Files table has LastDownloadTime field which is of type DateTime.
This is my SQL query;
Select
Users.Name , Files.Name
FROM Users
RIGHT OUTER JOIN Files on Users.ID = (
Select Files.UserID
FROM Files
ORDER BY LastDownloadTime DESC Limit 1
)
Above query returns all Users and Files. What should be the right query for this?
You could do this: