I want to select the last record from thousands of records, how to write the SQL query for that.

Recommended Answers

All 5 Replies

SELECT TOP 1000 * FROM <TABLENAME> ORDER BY ID DESC

But i belive this should have been posted under Database, not JavaScript...

write your select, order it in reverse order (o what you want is first) and add 'limit 1' at the end of the statement. That will give you exactly what would have been the last record before the change.

Sorry, I couldn't think of a way to demonstrate this in DHTML or AJAX. :D :D

how select last record in sql

One answer to your question is given in the post immediately above yours in this thread from two years ago.
If you need more information you will probably have better luck in the Databases forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.