Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-04-2009
Member
 
Join Date: Nov 2008
Posts: 1,185
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?
Reply With Quote
  #2  
Old 22-04-2009
Member
 
Join Date: Feb 2008
Posts: 194
Re: Select the last 10 records related to a date

With an "order by tadate desc limit 10" it should solve your problem.
Reply With Quote
  #3  
Old 22-04-2009
Member
 
Join Date: Nov 2008
Posts: 1,185
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!
Reply With Quote
  #4  
Old 22-04-2009
Member
 
Join Date: Feb 2008
Posts: 194
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?
Reply With Quote
  #5  
Old 22-04-2009
Member
 
Join Date: Nov 2008
Posts: 1,185
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)
Reply With Quote
  #6  
Old 22-04-2009
Member
 
Join Date: May 2008
Posts: 3,971
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Select the last 10 records related to a date"
Thread Thread Starter Forum Replies Last Post
Select Unique Values (Selecting The Most Recent Record Based On Date) Leeland Software Development 4 14-05-2010 12:16 AM
PHP mysql select unique records from one table Captain Carrot Software Development 6 13-05-2010 12:18 PM
Select unique records from a table Conraad Software Development 5 13-05-2010 12:01 AM
How to select previous month's date? Saaz Software Development 3 14-11-2009 02:07 PM
How to Querying blank records iso date in access Quattro Windows Software 3 31-07-2009 10:20 AM


All times are GMT +5.5. The time now is 01:48 PM.