Results 1 to 2 of 2

Thread: Retriving Last Row Added From a Table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Mexico
    Posts
    24

    Question

    Hello, How do you get e.j. the last 10 rows added to any table?
    Thanks!
    Chicho

  2. #2
    Guest
    Chicho,

    this depends on the database you are using and of your database design. let's assume you have an Access database.

    1.
    your table has one field of type autovalue. in this case just retrieve the first 10 records of a view sorted 'desc' by your autovalue field.

    SELECT TOP 10 * FROM tblEmployees
    ORDER BY Id DESC

    2.
    your table has no autovalue - field. in this case add a field of format date/time and set the 'default value' to 'Now()'. do the same as in the previous suggestion but this time use your date/time field.

    SELECT TOP 10 * FROM tblEmployees
    ORDER BY TimeStamp DESC

    hope this helps

    Sascha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width