db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francois Orsini" <francois.ors...@gmail.com>
Subject Re: Top 1 - Limit 1
Date Fri, 15 Sep 2006 02:43:46 GMT
On 9/14/06, Marl Atkins <marl@softlinksys.com> wrote:
>
> This would only work if the ID field is an Identity.
> As it happens, it IS so this should work for me too.
>
> THREE answers to my problem.


That's one of the nice aspects of  Open Source

You get Open Assistance :) or Open Support however you want to call it.

You guys are good THANKS!!
>
> -----Original Message-----
> From: Dan Scott [mailto:denials@gmail.com]
> Sent: Thursday, September 14, 2006 7:28 PM
> To: Derby Discussion
> Subject: Re: Top 1 - Limit 1
>
> I think the IDENTITY_VAL_LOCAL() function is what Marl is actually looking
> for. http://db.apache.org/derby/docs/10.1/ref/rrefidentityvallocal.html
>
> Dan
>
> On 14/09/06, Bernt M. Johnsen <Bernt.Johnsen@sun.com> wrote:
> > Marl Atkins wrote:
> > > Hi:
> > >
> > > I'm searching the docs and can't find it.
> > > Is there a way to limit the number of records in the result like:
> > >
> > > Sql Server: Select Top 1 * From MyRecs ORDER BY ID DESC
> > > MySql:      Select * From MyRecs ORDER BY ID DESC LIMIT 1
> > >
> > > Basically, I need the ID of the last record inserted.
> > > How can I get that?
> >
> > e.g. by calling stmt.setMaxRows(1);
> >
> > but it will not give you the *last* record inserted (SQL is a set
> > language!). It will give you the row with the *highest* ID.
> >
> > What about
> >
> > select * from MyRecs where ID in (select max(ID) from MyRecs)
> >
> >
> > >
> > > Marl K. Atkins
> > > Microsoft Certified Professional
> > > SoftLink Systems, Inc.
> > > (407) 388-1886
> > >
> >
> >
> > --
> > Bernt Marius Johnsen, Database Technology Group, Staff Engineer,
> > Technical Lead Derby/Java DB Sun Microsystems, Trondheim, Norway
> >
>
>

Mime
View raw message