Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 6th, 2006, 11:09 AM
Authorized User
 
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing the latest row in a table

Hello guys..

I have a problem. I need to access the latest row in an sql database table. I didnt find anyway for that..So please any one help me!!!!!

Pramod

 
Old April 6th, 2006, 11:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

What do you mean by "latest row"?

Concepts like "latest", "earliest", "first", "next", etc. only have meaning when you are dealing with an ordered set of data. Since rows in a table in a relational database are inherently unordered, none of these concepts have any meaning.

Is there a column in your table which allows you to order the row data? For example, if you have a datetime column such as 'DateEntered', then you could easily find the row with the maximum value, and that would correspond to the 'latest' row.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old April 6th, 2006, 06:56 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

http://p2p.wrox.com/topic.asp?TOPIC_ID=40967

May be what you are looking for. This explains how to get the most recently inserted record. It does assume you have an auto incrimenting integer as a promary key field in your table, do you? If not, why not. IMO even if you dont need it, throw it in there - there is a good chance you may need it in the future.

Others:
There is an un-answered question in this post, I am most interested to hear opinions on it

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
The latest row entered in a database Table pramos.21d BOOK: Beginning SQL 1 August 3rd, 2006 05:18 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
Problem accessing table tlamazares SQL Server ASP 2 December 16th, 2003 04:03 PM





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