Friday, October 30, 2009

Get the last entry from a database table

Let's say you got a table(Users) with 3 fields(ID, FirstName and LastName), you need to get the last ID entry in that table, in this case you can use this nice SQL function
SELECT MAX("ID") FROM "Users";
you can do same for any other field, let's say FirstName
SELECT MAX("FirstName") FROM "Users";
MAX - is a SQL function which returns the last entry in the specified table.

No comments:

Post a Comment

Blogroll(General programming and Delphi feeds)