I've done research on this problem, but am having trouble finding a solution.
I have the following query that gives me a list of "some_id"s:
SELECT some_id FROM example GROUP BY some_id
And I have the following query that will get a list of the 5 most recent entries for a row that has "some_id" equal to a number.
SELECT * FROM example
WHERE some_id = 1
ORDER BY last_modified DESC
LIMIT 5
How can I get the the top 5 most recent entries from the table "example" for each "some_id", using only one query? If there are less than 5 entries for a "some_id", it is okay to include them, if that makes things less complex.
Many thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…