X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD273100B1 for ; Thu, 26 Jun 2003 23:26:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 40828-05 for ; Thu, 26 Jun 2003 20:26:33 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id B512530FF93 for ; Thu, 26 Jun 2003 20:26:32 -0300 (ADT) Received: (qmail 11447 invoked by uid 500); 26 Jun 2003 23:30:02 -0000 Date: Thu, 26 Jun 2003 18:30:01 -0500 From: Bruno Wolff III To: Josh Goldberg Cc: Michael Kovalcik , pgsql-admin@postgresql.org Subject: Re: How do I select the last Id in a column??? Message-ID: <20030626233001.GA11420@wolff.to> Mail-Followup-To: Josh Goldberg , Michael Kovalcik , pgsql-admin@postgresql.org References: <20030623184706.75021.qmail@web11101.mail.yahoo.com> <01f401c33c25$fbffd5d0$6e02a8c0@4dmatrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01f401c33c25$fbffd5d0$6e02a8c0@4dmatrix.com> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/309 X-Sequence-Number: 9300 On Thu, Jun 26, 2003 at 14:00:33 -0700, Josh Goldberg wrote: > to get the last record inserted just > select * from row order by autoincId desc limit 1; > > if you have several clients doing this you might want to put your insert and > the select inside a transaction. That won't help. Your suggestion will only work in serializable transactions. In read committed mode the select might see a value for autoincId from a transaction that committed between the insert and the select.