-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Getting the last (integer) id from a table
PostPosted: Wed May 25, 2005 7:08 pm 
Newbie

Joined: Sat Apr 23, 2005 10:50 pm
Posts: 17
Hi, this is a very easy question, but I don't seem to get it anyway.
I have table representing a SalesLineItem class, the table's name
is saleslineitem and is shown here below:

create table saleslineitem (
id int not null auto_increment primary key,
price double,
total double,
code text,
qty int,
name text,
description text
);

My question is, how to get the last id.
Suppose we have three rows inserted in that table, then the last id
is 3.
I want to retrieve the last id, but how?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 10:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
select max(sli.id) from SalesLineItem sli


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.