Results 1 to 6 of 6

Thread: Select the last 10 records related to a date

  1. #1
    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?

  2. #2
    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.

  3. #3
    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!

  4. #4
    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?

  5. #5
    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)

  6. #6
    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

Similar Threads

  1. Replies: 4
    Last Post: 14-05-2010, 12:16 AM
  2. PHP mysql select unique records from one table
    By Captain Carrot in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 12:18 PM
  3. Select unique records from a table
    By Conraad in forum Software Development
    Replies: 5
    Last Post: 13-05-2010, 12:01 AM
  4. How to select previous month's date?
    By Saaz in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 02:07 PM
  5. How to Querying blank records iso date in access
    By Quattro in forum Windows Software
    Replies: 3
    Last Post: 31-07-2009, 10:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,477,500.14888 seconds with 16 queries