Select the last 10 records related to a date
I do a select a bit special
I have records that contain an ID and a Date. The same ID can be present several times on the same date. I would like to select all the ID on 10 separate dates last?
Is this possible in MySQL or do I do this programmatically?
Re: Select the last 10 records related to a date
With an "order by tadate desc limit 10" it should solve your problem.
Re: Select the last 10 records related to a date
This is clearly not as simple!
I want the last 10 dates addresses
So if I have 10 different addresses on many dates do I have 100 records as a result!
Re: Select the last 10 records related to a date
Here I believe that without this program will not be possible. What you have at your disposal?
Re: Select the last 10 records related to a date
Yes I fear also. As for the code but for the performance!
I'm in C#. But it means that I will have to load a table using a select where date> something (to avoid loading too)
Re: Select the last 10 records related to a date
This is not necessarily beautiful, but with a recent MySQL that will occur:
Code:
SELECT .* Tbis
FROM (SELECT DISTINCT date
FROM tbl
ORDER BY date DESC LIMIT 10) AS TopTen
JOIN tbl AS ON Tbis tbis.date = topten.val