Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes Search for last record and display contents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Search for last record and display contents" Watch "Search for last record and display contents" New topic
Author

Search for last record and display contents

Annemarie McKeown
Ranch Hand

Joined: Nov 07, 2003
Posts: 47
How do you search for the last record entered in your table. What query would I use to do this?
Many thanks.
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
If you have a table with a nice auto-incrementing primary key column defined as an integer etc, you could issue:
select * from mytable
where myprimarykey = (select max(myprimarykey) from mytable)
Annemarie McKeown
Ranch Hand

Joined: Nov 07, 2003
Posts: 47
Thanks James, worked out fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Search for last record and display contents
 
Similar Threads
Lock implementation
determing # of rows in recordset
[B&S] GUI Search
barry boone exam answers
Best way to keep track of record in JTable