I want to fetch data from a huge db that same ID number each yea , but different photo for each date
I want query to filter and show result with Last date including (ID and photo) to the given ID
Advertisement
Answer
Possibly the most efficient method is:
select n.* from nid n where n.date = (select max(n2.date) from nid n2 where n2.id = n.id);
For performance, you want an index on nid(id, date)
.