Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.27/5 (5 votes)
See more:
how to retrieve last record set from sql database
Posted
Updated 22-Nov-15 17:07pm
v2
Comments
Suvendu Shekhar Giri 22-Nov-15 22:30pm    
Not Clear. Tagged VB but question is for SQL Query.
Last record set means?
SQL Database means? SQL Server or MySQL or ??
PIEBALDconsult 22-Nov-15 23:08pm    
Whatever you retrived last is the last.
Liju Sankar 23-Nov-15 0:09am    
What is your database ? is it SQL Server or Ms-access or MySQL or ...
ElLo25 24-Nov-15 20:44pm    
MS-access

Use Last()
SELECT LAST(column_name) FROM table_name;
But the LAST() function is only supported in MS Access, hence you can do something like this-

SQL Server
SELECT TOP 1 column_name FROM table_name<br />
ORDER BY column_name DESC;


MySQL
SELECT CustomerName FROM Customers<br />
ORDER BY CustomerID DESC<br />
LIMIT 1;


-KR
 
Share this answer
 
v2
Comments
Arasappan 22-Nov-15 23:36pm    
ha ha....
Krunal Rohit 22-Nov-15 23:38pm    
Yeah, I forgot to mention the link. Thanks for saving my back :)

-KR
Arasappan 22-Nov-15 23:40pm    
:)
Krunal Rohit 23-Nov-15 1:28am    
To the down-voters: At least leave a comment for the down-voting an answer.

-KR
SQL
SELECT TOP 1 column_name FROM table_name
ORDER BY column_name DESC;


http://www.w3schools.com/sql/sql_func_last.asp[^]
 
Share this answer
 
v2
Comments
Arasappan 23-Nov-15 0:31am    
who is downvoted...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900