X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D70E1D1B8E0 for ; Mon, 1 Sep 2003 18:55:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66955-04 for ; Mon, 1 Sep 2003 15:55:17 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 8D887D1B8C9 for ; Mon, 1 Sep 2003 15:55:15 -0300 (ADT) Received: (qmail 1831 invoked by uid 500); 1 Sep 2003 19:01:22 -0000 Date: Mon, 1 Sep 2003 14:01:22 -0500 From: Bruno Wolff III To: Andrei Verovski Cc: pgsql-php@postgresql.org Subject: Re: Get last serial (autoincrement) value Message-ID: <20030901190122.GA1782@wolff.to> Mail-Followup-To: Andrei Verovski , pgsql-php@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/4 X-Sequence-Number: 2281 On Mon, Sep 01, 2003 at 13:34:32 +0300, Andrei Verovski wrote: > > Anyone knows how to obtain last inserted serial (autoincrement) id? I > am currently using "SELECT id FROM table_name ORDER BY id DESC", and > then retrieve first row and desired value. How you want to do this, depends on what you what to do with the number. Normally if you just inserted a record that would create a new id and you want to use that id to enter in another table, then you want to call currval.