Hello, How do you get e.j. the last 10 rows added to any table?
Thanks!
Chicho
Printable View
Hello, How do you get e.j. the last 10 rows added to any table?
Thanks!
Chicho
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