Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retreive last record

 
deepa karra
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to retreive last inserted record of a table. No records are displayed when i use the following query





 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepa,
What does that mean? A database doesn't promise to keep rows in a certain order? It is more logical to want the first/last alphabetically or sorted by some key.
 
Mark Dahlerup
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an "AND" clause which means you only get a row back if the 'last' row has the USERNAME you have entered
try

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Deepa,
What does that mean? A database doesn't promise to keep rows in a certain order? It is more logical to want the first/last alphabetically or sorted by some key.


Well, though you are right that logical rather then physical ordering is the way to think about retreiving data from RDBMS's, you can specify the storage order in some databases (SQL Server and Oracel spring to mind) by using clustered indices.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic