Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 46174 invoked from network); 14 Sep 2006 23:29:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Sep 2006 23:29:05 -0000 Received: (qmail 56834 invoked by uid 500); 14 Sep 2006 23:29:04 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 56390 invoked by uid 500); 14 Sep 2006 23:29:02 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 56373 invoked by uid 99); 14 Sep 2006 23:29:01 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of denials@gmail.com designates 66.249.82.225 as permitted sender) Received: from [66.249.82.225] (HELO wx-out-0506.google.com) (66.249.82.225) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 16:28:59 -0700 Received: by wx-out-0506.google.com with SMTP id i27so2915499wxd for ; Thu, 14 Sep 2006 16:27:39 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=t76TuvmpKJ9fvPQ+oCCzvNsx7ZpGGspLxCTczDdAzZkUJMiiy0MBtrDRIbcysh3eYgz/KqEfuCy5fesVvE9VU1IOFB7nNYT2OxH0IlxlMCSlM2U1ylK6eFP2H4QTwUiwZePXtkk6QjNRevxSOfGrwcCjWsjsM8E9Swt5vHGL5Pg= Received: by 10.90.49.20 with SMTP id w20mr3536877agw; Thu, 14 Sep 2006 16:27:38 -0700 (PDT) Received: by 10.90.78.19 with HTTP; Thu, 14 Sep 2006 16:27:37 -0700 (PDT) Message-ID: Date: Thu, 14 Sep 2006 19:27:37 -0400 From: "Dan Scott" To: "Derby Discussion" Subject: Re: Top 1 - Limit 1 In-Reply-To: <4509EDEA.5090909@Sun.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <003401c6d847$e5a548d0$6401a8c0@matkins> <4509EDEA.5090909@Sun.COM> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 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 >