Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > BOOK: Beginning SQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 5th, 2006, 07:48 AM
Authorized User
 
Join Date: Mar 2005
Location: , , .
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?

Reply With Quote
  #2 (permalink)  
Old August 3rd, 2006, 06:18 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing the latest row in a table pramos.21d SQL Language 2 April 6th, 2006 07:56 PM
How to access the latest row pramos.21d ADO.NET 0 April 5th, 2006 07: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



All times are GMT -4. The time now is 03:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.