Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > BOOK: Beginning SQL
|
BOOK: Beginning SQL
This is the forum to discuss the Wrox book Beginning SQL by Paul Wilton, John Colby; ISBN: 9780764577321
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2006, 06:48 AM
Authorized User
 
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default The latest row entered in a database Table

In Sql database table how to retrieve the latest data entered? what is the code for that?

 
Old August 3rd, 2006, 05:18 PM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have an ID field, just get the record with the highest ID. Something like:
SELECT * FROM table WHERE Id = (SELECT Max(Id) FROM table)

You could also just do SELECT * FROM table ORDER BY Id DESC, and get a set with the newest record first. In the programming language you're using to execute the SQL commands, you could then just access the first record in the set.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing the latest row in a table pramos.21d SQL Language 2 April 6th, 2006 06:56 PM
How to access the latest row pramos.21d ADO.NET 0 April 5th, 2006 06:57 AM
UPDATING 1 row with another row in same table rit01 SQL Server 2000 3 February 19th, 2006 08:55 AM
first row of a table Adam H-W SQL Language 2 January 11th, 2005 10:15 AM
How to duplicate 1 row in table minhpx SQL Language 1 December 20th, 2004 09:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.